AS3 TextField metrics bug

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

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.

Using a timeline animation as alpha mask

I guess you know, that you have to set the cacheAsBitmap property of both, the mask and the masked Sprite, to apply an alpha mask.

...
mask.cacheAsBitmap = true;
container.mask = mask;
container.cacheAsBitmap = true;
...

This works perfectly with a static bitmap mask but if you try to do the same with an animated MovieClip mask, the mask will not work anymore. Apparently the cacheAsBitmap property of the MovieClip is reset on entering a new frame and therefore to get it working you have to set cacheAsBitmap = true in every frame.

...
mask.cacheAsBitmap = true;
container.mask = mask;
container.cacheAsBitmap = true;
 
addEventListener(Event.ENTER_FRAME, frameHandler);
 
function frameHandler(event : Event) : void
{
	mask.cacheAsBitmap = true;
}
 
...

Masking a 3D Container in AS3 (FP10)

»Easily transform and animate any display object through 3D space while retaining full interactivity.« That’s one of the key features in FlashPlayer 10 according to Adobe. You might think: "Woohoo, that’s fantastic" … so did I. But actually this is not completely true.

I was trying to set a mask or the scrollRect-property of a Sprite and as long as you don’t use one of the new 3D properties (rotationX, rotationY, rotationZ, …) this works as supposed. After changing one of the 3D properties and therefore using the new 3D API the mask will not work anymore. Of course this is not mentioned in the FP10 AS3 reference.

Digital Graffiti – Spray Demo

The canvas with the van is not very nice, but just to show you a demo of the spray can. sorry for my bad spraying skills. see a description of the project here.

« Older Entries

Newer Entries »

About

Martin Rädlinger is an Interactive Developer & Designer. He specializes in interactive coding predominantly with ActionScript, but every new challenge is welcome. If you like his work feel free to get in touch with him. At the moment he's available for freelance work.

Contact

Martin Rädlinger
mail: mr [at] formatlos.de
web: www.formatlos.de
xing: Martin Rädlinger
linkedin: Martin Rädlinger
skype: martinraedlinger