• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

Keep Custom Cursor At the Highest Depth

I'm adding a custom cursor, and I need it to stay at the highest depth. Currently, whenever I add new movie clips to the screen, the custom mouse shows up behind the movie clips, which looks terrible.  I have to add movie clips regularly during runtime, but I need the custom cursor to stay above them, just like the regular mouse would.

Here's how I'm adding the custom cursor:

                        Mouse.hide();
                  var cross= new crosshairs();
                  this.addChild(cross);
                  cross.depth = 999999;
                  cross.startDrag(true);
                       
0
walker6o9
Asked:
walker6o9
  • 2
1 Solution
 
blue-genieCommented:
walker are you trying to do this in AS2 or AS3?
0
 
cconstable_workCommented:
What version of Actionscript are you using?
You could:
this.addChildAt(cross, 0);

Then all other movie clips:
this.addChildAt(other_mc, 0);

this would ensure that the cross is continually pushed to the top when a new movie clip is added.

Or you could add a new container movie clip for your cursor and another container for everything else.

import flash.display.MovieClip;

var myMouseContainer:MovieClip = new MovieClip();
var myEverythingElseContainer:MovieClip = new MovieClip();
stage.addChild(myEverythingElseContainer);
stage.addChild(myMouseContainer);
var myCross:MovieClip = new cross_mc();
var myEverythingElse:MovieClip = new block_mc();
myMouseContainer.addChild(myCross);
myEverythingElseContainer.addChild(myEverythingElse);
0
 
walker6o9Author Commented:
This works, except that I can't click on anything.
0
 
cconstable_workCommented:
Again not sure what version of action script you are using.
If you have a movie clip covering other movie clips and need to be able to click through it add:
my_mc.mouseEnabled = false;
this will stop the movie clip from being click-able which allows you to click things under it.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now