Archive for April, 2009
AS3 TextField metrics bug
April 9th, 2009 • 2 comments ActionScript, Flash
Tags: ActionScript, AS3, Flash, TextField
Just a quick reminder for myself. There are a few interesting metrics functions in the AS3 TextField API like getCharBoundaries(), but if you have an autoSize field the methods won’t work properly. Just set the height of the field before calling the method to fix that.
... textfield.height = textfield.height; textfield.getCharBoundaries(charIndex); ...
Flash Image Sequence Memory Issues
April 9th, 2009 • 3 comments ActionScript, Flash
Tags: ActionScript, AS3, BitmapData, Flash
I guess most of you are aware of the Bitmap memory leak in Flash Player and that you have to call the BitmapData.dispose() method to actually free the memory. But what to do if you don’t have a reference to the BitmapData?
That’s essentially a problem when dealing with MovieClips with an image sequence on its timeline. After adding the MovieClip to the stage and accessing each frame the complete sequence is in memory and removing it from the stage again doesn’t free any of this memory. Obviously the single frames are getting converted to Shapes with bitmap fill internally, so you don’t have a Bitmap instance for each frame and therefore you can’t dispose the frames after showing the sequence.
Sequence Example (the swf has no preloader, so you’ll probably have to wait a little bit)
Sequence Example Source (9MB, Flash CS3)
The only solution for this problem is to load the sequence as an external swf and call the unload method of your Loader instance when you don’t need the sequence anymore and want to free the memory. Alternatively you could load the single jpg frames individually, create your sequence programmatically and use BitmapData.dispose() afterwards.


