blog
Quick tip: Embedded MovieClip not MovieClip? at Jozef Chúťka's blog
May 6, 2010
embed Flash Flex MovieClip Sprite TypeError
Quick tip: Embedded MovieClip not MovieClip?
When embedding MovieClips (with only one frame) from Flash .swf file into your Flex projects, you can fall into runtime issues:
[Embed(source="assets/preloader.swf", symbol="preloader")]
public static const PRELOADER_CLASS:Class;
MovieClip(new Assets.PRELOADER_CLASS());TypeError: Error #1034: Type Coercion failed: cannot convert *** to flash.display.MovieClip.Why coercion failed when my symbol is for sure MovieClip? The answer is simple:
Flash will type the symbol based on the number of frames in it’s timeline. If the symbol has only 1 frame it will be typed as a Sprite, 2 or more frames it will be typed as a MovieClip.
Possible solutions:
add 1 more frame (so the frame count is more than 1)
or cast embedded asset as flash.display.Sprite (prefered while there is no need for MovieClip with one usable frame + Sprite container consumes less memory)
The day is saved thanks to Felix Turner.
You may Leave a comment or Subscribe to Comments RSS or Trackback this entry.
Leave a comment
Please be polite and on topic. Your e-mail will never be published.