Skip to main content
Inspiring
February 26, 2010
Answered

Why swapDepth but no setDepth?

  • February 26, 2010
  • 1 reply
  • 1550 views

Why does the MovieClip class have no setDepth method? Why should we use swapDepth when a setDepth method is the easier way to set a movieclip's depth? Is it because setting of depth should be done by another class like DepthManager?

This topic has been closed for replies.
Correct answer kglad

swapDepths() can be used to set a depth so there's no point in adding a setDepth() method:

yourMC.swapDepths(10);  // assigns yourMC to depth 10

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
February 26, 2010

swapDepths() can be used to set a depth so there's no point in adding a setDepth() method:

yourMC.swapDepths(10);  // assigns yourMC to depth 10

Inspiring
February 27, 2010

Oh, i didn't know i can swap depths by specifying a numeric value and all this time i was doing complicated routines to swap depths of movieclips in a gallery. Thanks.

Inspiring
February 27, 2010

Yeah, there is really no substitute for reading the documentation!

BTW, here is a great article about how depths work in AS2. I highly recommend it:

http://www.kirupa.com/developer/actionscript/depths.htm