PDA

View Full Version : mouse trail + custom pointer


phax
03-12-2003, 02:29 AM
i've playing around with these turtorials and trying
to make a custom pointer with a mouse trail..

everyting works fine except that the mouse trail
is on top of the pointer!

like this (http://www.users.bigpond.net.au/phixion/mouse_trail.html)


I have this code on the mouse trail mc;
onClipEvent (mouseMove) {
i++;
this.duplicateMovieClip("flare"+i, i+10);
_root["flare"+i]._x = _root._xmouse;
_root["flare"+i]._y = _root._ymouse;
}
onClipEvent (enterFrame) {
if (this._name == "flareMC") {
_visible = 0;
} else {
this._alpha -= 5;
this._rotation += 2;
this._xscale -= 5;
this._yscale -= 5;
if (this._alpha<=5) {
removeMovieClip(this);
}
}
}


And this on the mouse pointer mc
onClipEvent (load) {
Mouse.hide();
}
onClipEvent (mouseMove) {
setProperty(this, _x, _root._xmouse);
setProperty(this, _y, _root._ymouse);
updateAfterEvent();
}


any clue?

Jesse
03-12-2003, 04:47 AM
You can:
a) attach your custom point using attachMovie to some very high level rather than manually dropping it on the stage to ensure it's higher than all other elements
b) Use negative levels for your trailer elements (flash goes as low as - 17,000 or something crasy)
c) Use swapDepths which would kill the performance of your ap.

I'd suggest option A. If you're using Flash MX you can just use:
this.attachMovie("myMouse","myMouse_mc",1000);
myMouse_mc.onLoad = function () {
Mouse.hide();
}
myMouse_mc.onEnterFrame = function () {
setProperty(this, _x, _root._xmouse);
setProperty(this, _y, _root._ymouse);
updateAfterEvent();
}
Also note that your code is not sustainable. You have to limt the top value of your incrimenting variable 'i' otherwise, after sufficient mouse moves it will always get to be on top of you cursor (as Flash has a finite number of levels)

phax
03-12-2003, 07:51 AM
hmm.... tried to follow a. but must have done something wrong somewhere...

(obviously i'm no hardcore actionscripter)



i've dropped by the .fla if anyone whould bother take a look at it!
thanks.

Jesse
03-12-2003, 08:04 AM
You were pretty close. Good effort. See attached. I've added a conditional on the spray image which resets the duplication level after 100 duplicates are made. This means that you only ever use levels 0 to 100 for spray images. This is good because when you try and reuse a used level it will remove the (now finished) animation of the spray that was placed on that level last time. If you just keep incrimenting your counter without looping ack you'll soon crash Flash.

phax
03-12-2003, 11:02 AM
hey it works! :D thanks for the help