Tech Journal
Latest Entries
- Preselecting Pulldowns in ExpressionEngine Standalone Edit Forms
- iPad is more than just an e-Reader
- My Favorite New Things From 2009
Tech and Design
- My Favorite New Things From 2009
- Five Things I’ve learned About Freelancing
- Interesting Data Visualization
- Hydrogen Car Design to be Released “Open Source”
- Chicago Design Archive
- Keynote ‘09 - “View Package Contents”
iPhone
- iPad is more than just an e-Reader
- iPhone App Showcases Hi-Def Holographic Recordings
- iPhone as Digital Swiss Army Knife
Web
- Skipping the Multi-entry Page in ExpressionEngine
- Opera Unite
- Assigning movie clips levels in Actionscript 3.0
- Opening Shadowbox windows from a link in Flash
- Passing FLV file paths to an AS 3.0 SWF with SWFobject
Motion
Assigning movie clips levels in Actionscript 3.0
June 04, 2009
I’m relatively new to Actionscript 3.0, but I recently took the pledge that any new projects I build will be in AS 3. Recreating the concepts of AS 2 in AS 3 can be a daunting task. One issue I ran into today, was learning how to assign a stacking order to externally loaded clips.
in Actionscript 2.0, you can load external or library movie clips into levels to create a stacking order of movie clips on the stage. For example, you might have a navigation clip that always loads at the highest level so it remains visible and on top of all other clips. In Actionscript 3.0, level functionality has been removed. In AS 3.0, you can recreate this effect by using setChildIndex. In AS 3, all external content must be loaded into a container and you can then set the z-index of the container. Loading an external swf and setting the z-index of its container is pretty straightforward. In the following example, I’ve created a function that loads an external SWF and assigns it a z-index. I’ve added an Event Listener to a button (actually, a movie clip) on the stage that calls this function when clicked:
function doLoad01(event:Event):void {
var request:URLRequest = new URLRequest("myClip.swf");
var ldr01:Loader = new Loader(); //
this.addChild(ldr01); // "this" = the stage, the "child" is the loader container
this.setChildIndex(ldr01, 10); //this sets the z-index of the swf's container, "ldr01", to level 10
ldr01.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
ldr01.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
ldr01.load(request);
}
As you can see, the method for loading clips and sending them to levels is pretty straight-forward, but compared to AS 2 has changed quite radically.

Leave a Comment