Blog Post RSS ?

Blogs » Flash » Quick and Easy Depth Tricks
 

Quick and Easy Depth Tricks

by sgrosvenor

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<15; 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!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Ping.fm
  • Twitthis

Related posts:

  1. Better Selections In Photoshop With Quick Masks The Quick Mask in Photoshop offers a really easy way...
  2. Selections In Photoshop, Part 4: Tips & Tricks In the final part of our series on Selections in...
  3. Five Photoshop Layers Speed Tricks Jennifer shows you five quick tricks to speed up your...
  4. Why You Should Be Using Press Releases to Promote Your Business In the first of a two-part series on press releases,...
  5. Quick and Easy Graphing with the Google Chart API The Google Chart API makes creating simple charts and graphs...

This post has 10 responses so far

Sponsored Links

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Follow SitePoint on...