Skip to main content
Participant
March 9, 2018
Question

ActionScript 3.0 Mouse Over and Mouse Out scripting error

  • March 9, 2018
  • 1 reply
  • 3144 views

Trying to figure out a way to reverse a movie clip when I Mouse out.

here's my code right now:

Image_zoom.stop();

Image_zoom.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_3);

function fl_MouseOverHandler_3(event:MouseEvent):void

{

    Image_zoom.play();

}

It plays the video when I hover over with my mouse but when I move my cursor off it pauses the movie clip. Can it reverse on a mouse out regardless of play point.

Anything will help!

Thanks!

This topic has been closed for replies.

1 reply

JoãoCésar17023019
Community Expert
Community Expert
March 9, 2018

Hi.

This should do it:

import flash.events.MouseEvent;

import flash.events.Event;

import flash.display.MovieClip;

var mc:MovieClip = rec;

function mouseHandler(e:MouseEvent):void

{

    if (e.type == MouseEvent.MOUSE_OVER)

    {

        mc.forward = true;

        stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

    }      

    else if (e.type == MouseEvent.MOUSE_OUT)

        mc.forward = false;

}

function enterFrameHandler(e:Event):void

{  

    if (mc.forward)

        mc.nextFrame();

    else if (mc.forward == false)

        mc.prevFrame();

  

    if (mc.currentFrame == 1)

        stage.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);

}

mc.stop();

mc.mouseChildren = false;

mc.addEventListener(MouseEvent.MOUSE_OVER, mouseHandler);

mc.addEventListener(MouseEvent.MOUSE_OUT, mouseHandler);

I hope it helps.

Regards,

JC