Categories Displayed in Flash

Flash: Some characters could not be converted to outlines…

Wierd, ran into this trying to track down another problem with Flash.  I reinstalled from the Web Premium DVD  just Flash CS3, which took like 45 minutes (WTF?!), booting up flash, opened a file tried publishing and got that error...and none of the fonts (just myriad pro) showed up anymore.

Restarting the machine fixed it.

Flash: 4 XML and TextField tips

Tip1:

Which converting back and forth between XML and Objects (e.g parsing), you can't use E4X like primitives e.g.


if(xml.@someAttribute != null) //won't work


Use


if(xml.hasOwnProperty("@someAttribute"){


instead.

Tip2:

Similar when comparing XML nodes you should probably convert it to a string first e.g.


switch(xml.@name.toString()) {

case "config":....

Tip3:

When dealing with TextFields and you to embed text into the fla, but want to scroll a textfield, and avoid loading text. By default the textfield will maximize to fit the size of whatever text is pasted into it, making it hard to layout

A solution is to use two dynamic TextFields, one for the scrolled display, the other a text holder, just paste the text into that making it as big as needed, then hiding it and copying the first textfield. via


body_txt.htmlText = hideMe_txt.text;
hideMe_txt.visible = false;

Tip4:

embed fonts with textfields in a layer masked by another layer with a graphic not over the clip. That way you can be sure what your getting, when working on the Timeline you will see everything, but when published it won't be visible. You can also and get precise letters, rather than embedding the entire font family in the library.

Flash:Flickering Animation, dissapearing animation => corrupted symbol

This is something I've hit a few times across several projects.  At some unknown event, animated movie clips will start flickering, like if you have a character the head will start to dissapear on or off.  Once one clip is broken, EVERY animation across the Fla will have flickering issues.  Like simple tweens will show the first few frames, cut out completely then show the last.

Not sure how this is caused, guessing it's more frequent if your merging Fla's.   The only solution I've found is going through animation by animation and trying them out in a separate Fla.  Finding the one that flickers, and deleting it and replacing it with a backup will correct...the entire file!

Flash: Centering and Scaling

Been working on some fluid layout and centering projects. For reference:

  • stage.width + stage.height - the size of the content on the stage.
  • stage.stageWidth + stage.stageHeight - that dimensions of the monitor the flash player is currently consuming
  • loaderInfo.width + loaderInfo.height - that of the Fla's publish settings

Got the 2nd and 3rd confused, so only started seeing problems when they were published (doh!)

Flash: Beware the Garbage Collector

Of all the major changes in AS3, this has been the most problematic....things hanging out off the display list, unreachable. I discovered a new way to get these "voices from the grave" to happen this eve.

We are instantiating new MovieClip classes for the stage via

  1.  
  2.      MovieClipClassReference = getDefinitionByName(styleMC) as Class;
  3.      try{
  4.            curPageClip = new MovieClipClassReference (curPageText);
  5.          }catch (e:Error){
  6.           curPageClip = new MovieClipClassReference ();
  7.       }

The idea being sometimes they accept an argument, in other times they don't. If it doesn't work the first time, then we try the second. Unfortunately this means that there are now 2 MovieClips, with all their assets hanging out in memory, but lacking the brains/script because the constructor errored out! In our case the error was 'voices from beyond' as the sounds embedded on the timeline were playing in the background even though there only appeared to be one instance on the stage stopped at the beginning.

The short solution for us was to have all classes accept a constructor, even if they don't do anything with it. A cleaner approach is to introspect the class looking for the amount of arguments in the constructor...

  1.  
  2.        var desc:XML = describeType(MovieClipClassReference );
  3.         var xmlL : XMLList = desc..constructor.parameter;
  4.         trace("Constructor Parameters " + xmlL.length());
  5.         if( xmlL.length() == 1) {
  6.                 curPageClip = new MovieClipClassReference (curPageText);
  7.         }else if( xmlL.length() == 0) {
  8.                 curPageClip = new MovieClipClassReference ();
  9.         }

Flash: Actionscript 3.0 ReferenceError: Error #1056 Cannot create property

Also discovered here Quote:

In Flash CS3, when you have instances (Movieclips) on the main timeline (Stage) with instance name on them and “Automatically declare stage instances” is off (File->Publish Setting->Flash->Actionscript 3.0 setting), You will need to declare properties for the document class with the same instance names or else you will get the error messages…

Like:


Cannot create property ANamedClipOnTheTimeline_mc on com.yoursite.DocumentLevelClass


at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at com.yoursite.DocumentLevelClass()

In my case this was due to copying a button that didn't belong, hidden behind another clip.  To Find it I selected all, Right Clicked, selected distributed to layers, and then deleted the offending layer named that of the clip named in the error.

Flash: Full window flash, and when minimum size scrollbars with SwfObject 2.0’s Dynamic Publishing

In the post "Elastic flash with scrollbars" a nice javascript library is presented to scale full window flash when the browser hits a certain. point. Worked great with SWFObject 1.0, but didn't work with SWFObject 2.0 and dynamic publishing without a tweak.

Here's the Javascript I'm using:

  1.  
  2.                         var params = {};
  3.                         params.allowscriptaccess  = "always";
  4.                         params.menu = false;
  5.                         var attributes = {};
  6.                         attributes.id = "flashUI"; // what to call with External Interface
  7.                         attributes.name = "flashUI";
  8.                         swfobject.embedSWF("index.swf", "contentToReplaceDiv", "100%", "100%", "9.0.0", "expressInstall.swf", fv, params, attributes);
  9.  
  10.                         var scale = new FlashScaler("flashUI", 1280,768);
  11.                         scale.resize();

This got the scaling to work but not on the original load, if the window was smaller than the minimum dimensions, as the load event has already been called. So I had to modify FlashScaler to call the resize function during constructor e.g.

  1.  
  2. function FlashScaler(flashdiv,w,h){
  3.  
  4.         var flashObj = document.getElementById(flashdiv);
  5.         var minW = w;
  6.         var minH = h;
  7.         addWindowEvent("onload",resize);
  8.         addWindowEvent("onresize",resize);
  9.         resize(); //<-- added this line
  10.        .........

SWFForceSize is similar. "Size limiting for full window flash" Not exactly sure how they differ internally, but the approach that might work is hinted in the documentation and API But only when static publishing via the use of

  1.  
  2. swfobject.getObjectById(objectIdStr)

and perhaps passing it into SWForceSize? Don't know.

UPDATE: FlashScaler with this approach doesn't work with IE6, or IE7, gives script errors, looking into it.

Flash: Tip to find Clips lost in the library

If you have deeply nested folders in the library and/or drag things in from other Fla's you might not be able to find where they are.  One tip is to find it, or  drag it to stage from the other Fla and right click 'swap symbol' it will pop open the library viewer where it's at.

Flash: “Error initializing Java Runtime Environment - You may need to reinstall Flash.”

I've been trying to create a swf with about 100MB of uncompressed jpegs in it.  Not surprisingly Flash opening it up expands to a whopping 1.5GB of ram, and then complains it ran out of memory during publishing it (even though the machine has 3GB of ram..), just prior to that it gives that error.

http://blog.tukker.org/2008/05/23/flash-cs3-error-initalizing-java-runtime-environment/

http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=612&threadid=1184131&messageid=4278084

This didn't make sense initially. But then I realized that adobe is likely using Java in the background to do the compilations, perhaps even embedding the FCSH.,  which  would allow them to write the very difficult compiler in a cross platform way.

This might also explain why Flash (and Flex/Eclipse) hang for periods of time, as this is typical of garbage collection, and the larger the memory the longer it takes to do the sweep.

Flash: Error #1009: Cannot access a property or method of a null object reference.

Here's another needle, in the heap and stack.

If you have an array and you trace it out like so:


var ary:Array = [1,2,3]

trace(ary);// outputs 1,2,3

Behind the scenes, each element in the collection has it's toString() function before returning the single string. This is fine and good. However, if there is an error in that in the toString(), Even with debugging enabled, errors won't show up with a line number, leaving you head-scratching. In my case the toString function was overridden from a parent class, and didn't initialize variables due to missing a super() in the subClass's constructor.