here is the code
Code:
[LEFT]
AS2 Version
onClipEvent (enterFrame) {
// Remember the scope of your clip it may not be in _root.
// if the mouse IS over the clip
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
// if the last frame of the tween hasn't been reached...
if (this._currentframe < this._totalframes) {
// keep playing the next frame to the last and stop...
this.nextFrame();
}
// if the mouse is NOT over the clip
} else {
// if we're past the first frame of the tween...
if (this._currentframe > 1) {
// play the previous frame until it reaches frame 1 and stop...
this.prevFrame();
}
}
}
this will no longer work in AS3 because you can not nest code on movie clips.
Any Ideas of how to convert to AS3?
AS3 Version
this.addEventListener (Event.ENTER_FRAME, detectObject);
function detectObject (e:Event) {
if (mouseX >= mc.x && mouseX <= mc.width +mc.x && mouseY >= mc.y && mouseY <= mc.height +mc.y) {
if (mc.currentFrame < mc.totalFrames) {
mc.nextFrame ();
}
} else {
if (mc.currentFrame > 1) {
mc.prevFrame ();
}
}
}
I have a close AS3 version but, it’s still not the same as it’s AS2 version:diss:
:::UPDATE::::
heres the working AS3 version
// mc is just a movieclip on the stage with a motiontween and a stop(); in the first key frame
this.addEventListener (Event.ENTER_FRAME, detectObject);
function detectObject (e:Event) {
if (mc.hitTestPoint(mouseX, mouseY,true)) {
if (mc.currentFrame < mc.totalFrames) {
mc.nextFrame ();
}
} else {
if (mc.currentFrame > 1) {
mc.prevFrame ();
}
}
}
}
[/LEFT]