0
votes

I am trying to use setChildIndex() to bring the current movieClip to the front.

I have the following code on the first frame of the TimeLine.

setChildIndex(currentMovieClip,numChildren – 1);

And am getting the following errors.

Scene 1, Layer 'Layer 2', Frame 1, Line 20 1093: Syntax error.

Scene 1, Layer 'Layer 2', Frame 1, Line 20 1084: Syntax error: expecting rightparen before 1.

Should I be using stage or something else is wrong?

Thanks

4

4 Answers

2
votes

This code will put the bottom-most object at the top:

this.setChildIndex(this.getChildAt(0), (this.numChildren-1));

EDIT:

Sorry, my first answer was wrong, here's the link to the documentation. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#setChildIndex()

4
votes
setChildIndex(currentMovieClip,numChildren - 1);

the - you were using was not correct, was another character :)

3
votes

If you only will put something on top, (guess it must be the same for movieclip as Sprites), you need only use addChild for the target once more and the object moves to the top.

addChild(a); //indexorder a
addChild(b); //indexorder ba
addChild(c); //indexorder cba
addChild(a); //indexorder acb
0
votes

you need a container.

var container:Sprite;

container.addChildAt(object);
container.serChildIndex(object,num);