FORUMS: list search recent posts

How to call the function play() once (no loop) on Mouse Over

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Denis Haska
How to call the function play() once (no loop) on Mouse Over
on Jan 19, 2014 at 9:17:06 am

Hello,

I am such a greenhorn for this code, and am trying to get this right from weeks now.
I am trying to make a the code for playing on every Mouse Over just once, but it keeps looping.

I have this:

this.home.addEventListener(MouseEvent.ROLL_OVER, function(e:MouseEvent): void{

play();

});

and I guess that I have to removeEventListener after if fires the first time with this like:

this.home.removeEventListener(MouseEvent.ROLL_OVER, arguments.callee);
play();

But it doesn't work. Any ideas please?

Deno


Return to posts index

Sam Mattern
Re: How to call the function play() once (no loop) on Mouse Over
on Jan 20, 2014 at 2:12:48 pm

If I understand correctly, you have an area that you want to animate when you mouse over. It plays its animation one time, but if you mouse over it again, it plays that animation again.

Assuming that's correct, you may just need to add a "stop();" on the first frame of the animation timeline so that it stops when it loops back to frame 1.

-Sam


Return to posts index

Denis Haska
Re: How to call the function play() once (no loop) on Mouse Over
on Jan 20, 2014 at 2:16:14 pm

Actually that does not work. Already tried it.


Return to posts index


Sam Mattern
Re: How to call the function play() once (no loop) on Mouse Over
on Jan 20, 2014 at 2:40:49 pm

Can you provide some more insight as to "does not work"?

Does it stop it from playing altogether or does it play but just keep looping?

-Sam


Return to posts index

Denis Haska
Re: How to call the function play() once (no loop) on Mouse Over
on Jan 20, 2014 at 2:48:47 pm

Sorry if I am not clear, and thank so much for trying to help.

If I put the stop() in the first frame with the rest of the code, and keep the mouse over the button area, the animation keeps looping. If I put stop() in the end frame, the animation plays once and no more.

I would want to make it play once when the mouse arrow is over for a second time, third time and so on.


Return to posts index

Sam Mattern
Re: How to call the function play() once (no loop) on Mouse Over
on Jan 20, 2014 at 3:23:02 pm

Okay, try putting the stop on the last frame and changing your play() command to "gotoAndPlay(1);". This specifies the frame to start playing from.

-Sam


Return to posts index


Denis Haska
Re: How to call the function play() once (no loop) on Mouse Over
on Jan 20, 2014 at 4:03:23 pm

Tried it, and am almost sure to have tried it before, so, if I put stop() in the last frame, then the animation does not play for a second time.


Return to posts index

Sam Mattern
Re: How to call the function play() once (no loop) on Mouse Over
on Jan 20, 2014 at 5:37:21 pm

I would change the following code, as it's not best practices and could be the source of your problem:

this.home.addEventListener(MouseEvent.ROLL_OVER, function(e:MouseEvent): void{
play();
});

That's really designed for a once and done function. Change it to:

this.home.addEventListener(MouseEvent.ROLL_OVER, homeOver);

function homeOver(e:MouseEvent):void{
this.home.gotoAndPlay(1);
}


See if that has any effect.

-Sam


Return to posts index

Denis Haska
Re: How to call the function play() once (no loop) on Mouse Over
on Jan 20, 2014 at 7:50:26 pm

That does not function as I would like either.

Anyway, I am sending the fla here, maybe you would have a bit of time to have a look.
In it there is another actionscript that I am testing, but feel free to use the code in the beggining of this thread as well.

https://www.hightail.com/dl?phi_action=app/orchestrateDownload&rurl=https%3A%2F%2Fwww.hightail.com%2Ftransfer.php%3Faction%3Dbatch_download%26batch_id%3DelNLb3BEQ0NiV3h3SGNUQw&s=19102&cid=tx-02002207340200000000


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]