HitTest and custom cursor


#1

Hi everybody,

Ok so this is what I am trying to accomplish…

I have a painters palette, and when the mouse is over the Palette, the mouse needs to change into a paint brush. I was able to use the hide mouse and start drag, and I was also able to use a hittest with the mouse an dthe the palette, but I can’t seem to get the code to work together…

any ideas, I am plum out!!!

but, here is my code, this code needs help, though!!!

start code:

onClipEvent (enterFrame) {
if (_root.hitTest(_root._xmouse,
_root._ymouse, false)) {
.Mouse.hide();
startDrag (“cursor”, true);
}
}

/end code

where the “cursor” is the name of the paint brushes M.C., and this code is inside of the palette’s M.C. A.C.

thank you in advance,


#2

What’s it doing, or not doing? Did you set the linkage for the cursor in the library?


#3

Okay here’s what you do:

what you want first is to have a movie clip follow your cursor, for that just slap the following onto any movieClip:

onClipEvent(enterFrame){
this._x=_root._xmouse;
this._y=_root._ymouse;
}

Then we fine it so that it only follows you mouse when your over a certain area:

  1. make a bigish button on the screen and add this to it:

on(rollOver){
_root.changeMouse=true;
}

on(rollOut){
_root.changeMouse=false;
}

Then add a variable on the frame called changeMouse and make it equal false by default.

next go back to your code on your chosen movieClipand refine it to:

onClipEvent(enterFrame){
if(_root.changeMouse==true){
this._x=_root._xmouse;
this._y=_root._ymouse;
}else{
this._x=-100;
this._y=-100;
}
}

what you have made is a switch that says if I’m over the hit area make me follow the mouse and if not move me off the stage, you could change the objects visibility instead of moving it off the stage but i leave it to you.

Dave


#4

MovieClip.prototype.mouseDrag = function (visible, targ, obj)
{
this[targ][obj]._visible = visible;
if (visible)
{
this[targ][obj]._x = this[targ]._xmouse;
this[targ][obj]._y = this[targ]._ymouse;
}
}

MovieClip.prototype.onMouseFocus() = function ()
{
this.tL = this._parent
this.onEnterFrame = function ()
{
if (this.hitTest (this.tL._xmouse, this.tL._ymouse, true))
{
Mouse.hide();
mouseDrag(true, this.tL, “cursor”)
}
else
{
Mouse.show();
mouseDrag(false, this.tL, “cursor”)
}
}

}

paletteMovieClip.onMouseFocus();

// just put the 2 functions in the root, then call paletteMovieClip.onMouseFocus();
on the same timeline that the paletteMovieClip is sitting on, and it should work ok :slight_smile:


#5

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.