PDA

View Full Version : swap children of stage from inside a child



rcfearn
April 26th, 2008, 03:19 AM
I have 9 movie clips which are all of the same object, they get larger or smaller as the mouse gets closer to their respective centers. The functionalilty for this is in an AS3 class file that extends flash.display.MovieClip.

How do I go about swapping depths so that the largest one is in the foreground, I am new to AS3 and dont seem to be able to find a way of getting the depth of the movieclip I am currently inside (this) and if I try to access the stage to call swapChildren I get the following runtime error:

The supplied DisplayObject must be a child of the caller

Any suggestions??

Regards
Rob

mechanicaltimi
April 26th, 2008, 04:10 AM
If you keep track of the children, swapChildren()

I believe that it takes two children as arguments and swaps their depth (front to back).

So if ones width and height is bigger, swap them.

mechanicaltimi

rcfearn
April 26th, 2008, 05:24 AM
If you keep track of the children, swapChildren()

I believe that it takes two children as arguments and swaps their depth (front to back).

So if ones width and height is bigger, swap them.

mechanicaltimi


This is not the issue I am aware of the swapChildren methods, even if I did keep track of the children I cant seem to make a swapChildren call from within one of the children.

magcius
April 26th, 2008, 08:32 AM
That error means that you're calling swapChildren with MovieClips are that are not a DIRECT child of the stage (I am assuming this is what you are calling swapChildren on).

rcfearn
April 26th, 2008, 08:53 PM
That error means that you're calling swapChildren with MovieClips are that are not a DIRECT child of the stage (I am assuming this is what you are calling swapChildren on).


The 9 movieclips have been dragged directly onto a blank stage, is their another way of doing this (without doing it programatically). I want the moviclips to act autonomously similar to a particle system, surely I shouldn't need to have external management code for such a simple system.

Felixz
April 27th, 2008, 09:39 AM
use root instead stage
look at graph here, http://livedocs.adobe.com/flash/9.0/main/00000142.html
stage is a container of root and all DisplayObjests are added to root, not stage

cheyennemtnman
January 13th, 2010, 10:06 AM
The 9 movieclips have been dragged directly onto a blank stage, is their another way of doing this (without doing it programatically). I want the moviclips to act autonomously similar to a particle system, surely I shouldn't need to have external management code for such a simple system.

Did you find a solution? I am trying to do a simple button scenario and I am having buttons overlap... I would just like a simple solution of the active button rises to the top when mouseover occurs...