MouseOver movieclip going back and forth on timeline
Hi, I have a 80 pictures showing an object in 360°. I want to be able to go back and forth on the timeline by moving the mouse to the left or to the right. How can I do that?
Hi, I have a 80 pictures showing an object in 360°. I want to be able to go back and forth on the timeline by moving the mouse to the left or to the right. How can I do that?
ClayUUID's code in message 3 gets the stage width, so you wouldn't need to put in values. If you wanted to go through all of the images in the time it takes to mouse across the movieclip itself, you could add the mouse move listener to the movieclip, and then there is a local x value you can use. The code would be:
myBla360.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
function mouseMoveHandler(evt:MouseEvent):void {
var percent:Number = evt.localX / myBla360.width;
percent = Math.max(0, Math.min(1, percent)); // clamp to 0 - 1 range
myBla360.gotoAndStop(percent * myBla360.totalFrames);
}
Hi This is what I was looking for. And it works!
myBla360.stop();
myBla360.addEventListener(MouseEvent.MOUSE_OVER,mover);
myBla360.addEventListener(MouseEvent.MOUSE_OUT,mout);
function mover(e:MouseEvent):void {
stopPlayReverse();
myBla360.play();
}
function mout(e:MouseEvent):void {
this.addEventListener(Event.ENTER_FRAME, playReverse, false, 0, true);
}
function playReverse(e:Event):void {
if (myBla360.currentFrame == 1) {
stopPlayReverse();
} else {
myBla360.prevFrame();
}
}
function stopPlayReverse():void {
if (this.hasEventListener(Event.ENTER_FRAME)) {
this.removeEventListener(Event.ENTER_FRAME, playReverse);
}
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.