Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

Flash CS4: The Overhead of 3D

Posted October 06, 2008 by senocular

Its no secret that Flash Player 10 now supports "3D Effects" - a new feature allowing developers manipulate display objects in a 3D coordinate space. The Flash CS4 authoring tool allows you to apply these effects to display objects on the stage and animate them over time using the timeline. If you do this, however, you may notice a dramatic jump in file size for your SWF. As soon as you make anything 3D, you've instantly added at least 13K to your published SWF. But why?
The reason has to do with the SWF file format and the implementation of the 3D in the player.

Everything you do on the timeline in Flash authoring is compiled into what are known as SWF tags in the resulting SWF file (in fact I recently posted about an ActionScript class that lets you read these tags). SWF tags are basically just chunks of binary data grouped together to represent something specific in the SWF such as a symbol, or a graphics tween, or even ActionScript. The progression of a timeline is based on the visual definitions of these SWF tags that define shapes and their transformations.

For Flash Player 10, no SWF tags were created (or updated) to support the new 3D transformations. All 3D requires ActionScript. What this means for Flash CS4 is that for a 3D-based timeline animation to function, it requires ActionScript. And that is where that extra file size comes from - the required ActionScript library CS4 uses to handle timeline based 3D animations.

Sadly file size isn't the only consequence of this implementation. Because ActionScript is being used to handle 3D, if at any point you try to use your own ActionScript to modify an existing 3D object on the stage that was defined as an animation on the timeline, you'll see a conflict with the internal ActionScript used to handle that animation. This is unlike custom ActionScript modifying other timeline objects which will "puppet" those objects taking them out of the scope of the timeline and into the scope of ActionScript, fully under your control (3D objects are already in the scope of ActionScript but being managed by internal scripts).

Hopefully this will help you make some sense of the side effects you might experience when working with 3D in the Flash CS4 authoring tool.