Skip to main content
Participant
April 11, 2011
Answered

setChildIndex problem

  • April 11, 2011
  • 2 replies
  • 440 views

Hello,

I have a problem and I hope someone can help me with it..

I made a small preloader
swf (preloader.swf) that loads greater swf file (materijal.swf). For this reason, all objects that are in "materijal.swf" are controled from "preloader.swf.

For example using the code:
MovieClip (mainLoader.content). Sah.sah1_1.addEventListener (MouseEvent.MOUSE_OVER, deoMouseOver);

The problem arises when I want to access a child, for example. "Sah1_1"

I need to put this child above others in some moment.
I tried with:
setChildIndex (MovieClip (mainLoader.content). sah.sah1_1, numChildren - 1);
All I get is error messages.

Can you tell me where I'm wrong,
you can download work files from:

http://www.sendspace.com/file/muhlde

Thanks in advance.

This topic has been closed for replies.
Correct answer kglad

just use addChild() to move a displayobject to the top of the parent's displaylist.

2 replies

Inspiring
April 11, 2011

Kglad's solution is the easiest and most workable. As for why yours is probably not working is that you aren't using the correc scope and all.

If you are trying to move sah1_1 which is a child of sah then you need the numChildren of sah, not the timeline the code is on.

MovieClip (mainLoader.content). sah.setChildIndex (MovieClip (mainLoader.content). sah.sah1_1, MovieClip(mainLoader.content).sah.numChildren - 1);

Or something like that.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 11, 2011

just use addChild() to move a displayobject to the top of the parent's displaylist.