Posts Tagged ‘Flash’

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.

BitmapData.draw() is limited to 4096px

Thanks to Jens I figured out another limitation in the BitmapData class. It’s actually buried in the draw() method which doesn’t copy any pixels to the BitmapData object whose target x-/y-position is greater than 4096px (0×1000). You don’t get any error just the pixels won’t be copied. This behavior is the same in FlashPlayer 9 and 10 and of course AIR 1.0 – 1.5.
Actually this is no problem for the regular use of BitmapData in FP9 because the BitmapData size is limited to 2880x2880px but using my BitmapDataUnlimited Class and trying to snapshot a Sprite wider or higher than 4096px won’t end up in your desired result.
As you probably know Adobe changed the BitmapData limit in FP10 to a more flexible one, so you are not limited by a specific size anymore but a maximum pixel count of 16,777,215. This means that you can have a BitmapData up to 8191x2048px without using BitmapDataUnlimited but interestingly you can’t draw a Sprite with the same size to this BitmapData object. I think Adobe forgot about their own secret, undocumented »feature«.

example

Sprite: w=8191, h=2048

FP10 BitmapData: w=8191, h=2048 with snapshot of the Sprite

workaround

A workaround for that problem would be to draw everything directly to the BitmapData or if you have to snapshot a Sprite greater than 4096px you could draw it to 4096px BitmapData chunks and copy them to the huge BitmapData afterwards using copyPixels().

Update December 14th, 2008

I added a draw method to the BitmapDataUnlimited class to bypass the 4096px limit.

Using RFID in an ActionScript Application

In order to receive tags, the RFID reader has to be activated through a click on the image. After that, the different RFID tags (sorry for my tiny tags) are used to create different forms.

Read more »

FlashPlayer 10 and loading AVM1 content

I’m using some swf assets directly exported from Illustrator CS3. You can export Flash 9 swfs, but as you can’t add any code there you will always get AVM1 content (AS2.0). So it’s basically just an information in the header and maybe Adobe will put an option in the export-settings to actually publish AVM2 swfs. I haven’t tried CS4 so far, maybe it’s in there already?!
Anyway, loading this swfs and moving it to another part of the displayList didn’t cause any problems using FlashPlayer 9. In FlashPlayer 10 I get the runtime error 2180:

Error #2180: It is illegal to move AVM1 content (AS1 or AS2) to a different part of the displayList when it has been loaded into AVM2 (AS3) content.

There are a few options to avoid this error:

  • Don’t load AVM1 content respectively create the assets in Flash to get AVM2 swfs
  • Don’t move the assets in a different part of the displayList
  • Change the SWF header on-the-fly

The last solution seemed to be perfect and remembering the AVM2Loader class someone created in the upcoming AS3 times it was the easiest solution without changing the workflow. Even if the author Fladdict removed the class, you can still find it on the internet at Troy Gardners blog.

Update 20.11.2008

To use this workaround in an AIR application you have to set allowLoadBytesCodeExecution = true in your LoaderContext otherwise you aren’t allowed to load the bytes of the swf.

...
var loader:Loader = new AVM2Loader();
var loaderContext:LoaderContext = new LoaderContext();
loaderContext.allowLoadBytesCodeExecution = true;
loader.load("file.swf", loaderContext);
...

« 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