Skip to main content
Participating Frequently
April 28, 2007
Answered

How does " bringToFront()" work?

  • April 28, 2007
  • 11 replies
  • 647 views
I have a movie clip in a game I am making, that replaces the mouse. I need it to be infront of everything else on the stage, and some things are attached from the library (so I can't controll their depth with layers anymore). I thought I had worked it out when I found the bringToFront(); function, but I don't think I am using it properly, because it doesn't turn blue like I thought it should, and it doesn't effect the depth of the movieclip. This is what i wrote:

var d = my_mc.bringToFront();

I would be greatful for any help. Thanks.
P
This topic has been closed for replies.
Correct answer dazzie7617784
The way I tend to do it is like this:-

aliendepthoffset = 1000;
numofaliens = 100;
alienxspacing = 18;
alienyspacing = 18;
numaliensinrow = 5;

for (i=0; i<numofaliens; i++) {
duplicateMovieClip(_root.alienclip , newname="myalien"+i, i + aliendepthoffset);
currentalien = eval("_root.myalien"+i);
currentalien._x = (i * alienxspacing) - (int(i/numaliensinrow)*( numaliensinrow*alienxspacing));
currentalien._y = int(i/numaliensinrow) * alienyspacing;
}



...whether that's particularly nice code or not, I'm sure there are better ways, but it gives you an idea of how I place them onto depth layers.

11 replies

April 28, 2007
I dont think bringToFront is a fvalid function. I didnt find it in the AS language reference.

What you need to do is swapth the depth of your curser MC with the depth of the movie clip you just attached from the library.
so if you attach this movie from the library:

this.attachMovie("myMovie", MyNewMovie",this.getNextHighestDepth())

you should then swap the depths:
MyNewMovie.swapthDepth(myCurserMC)