Quick and Easy Depth Tricks

I was rooting around in the Flash MX 2004′ sock drawer and stumbled across a rather nifty AS file (DepthControl.as) buried in the installation directory; a little further exploratory work and i was pleasantly surprised to find some very simple methods for depth shuffling (kinda cool if you’re into game or windowed application development).

Here’s the list of publically available functions for the class:


bringForward(target:MovieClip)
sendBackward(target:MovieClip)
bringToFront(target:MovieClip)
sendToBack(target:MovieClip):Void

And having created a simple movie clip with a linkage identifier of depthTest, I added the following code to the first frame of the timeline allowing simple press-release functionality to the duplicated MCs on the stage


for (i=0; i duplicateMovieClip("depthTest", ["depthTest"+i], i+5);
_root["depthTest"+i]._x = 50+(i*10);
_root["depthTest"+i]._y = 50+(i*10);
_root["depthTest"+i].onPress = function() {
mx.behaviors.DepthControl.bringForward(this);
};
_root["depthTest"+i].onRelease = function() {
mx.behaviors.DepthControl.sendBackward(this);
};
}

Now when I need to include any depth manipulation in my applications, I can simply include the class and call the functions through the prototype chain!

Replay

Category: software Time: 2004-05-23 Views: 1
Tags:

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.114 (s). 12 q(s)