Jump to content
GreenSock

ngrinchenko

What is the command to reset the TweenMax to play again

Recommended Posts

I play my Tween on MOUSE_OVER.

Then I would like it to be reset on MOUSE_OUT so when there is a MOUSE_OVER again on that MC - it plays again.

	ACOLYTE_mc.ACOLYTE_logo_btn.ACOLYTE_flash.alpha = 0;
	var  ACOLYTE_flash_Tween:TweenMax = TweenMax.fromTo(ACOLYTE_mc.ACOLYTE_logo_btn.ACOLYTE_flash, .25, {scaleX:.1, scaleY:.1},{scaleX:1, scaleY:.4, alpha:1, glowFilter:{color:0xffffff, alpha:1, blurX:12, blurY:5, strength:5, quality:3}, blurFilter:{blurX:12, blurY:4, quality:3}, repeat:1, yoyo:true, paused:true});

	ACOLYTE_mc.ACOLYTE_logo_btn.addEventListener(MouseEvent.ROLL_OVER, overHandler_ACOLYTE_logo_btn);
	ACOLYTE_mc.ACOLYTE_logo_btn.addEventListener(MouseEvent.ROLL_OUT, outHandler_ACOLYTE_logo_btn);
		 
		 
	function overHandler_ACOLYTE_logo_btn(e:MouseEvent):void{
         ACOLYTE_flash_Tween.play();
         trace("you rolled over me");
         }
         
	function outHandler_ACOLYTE_logo_btn(e:MouseEvent):void{
         ACOLYTE_flash_Tween.restart();
         trace("you rolled off me");
         }		

 

 

I want the tween to play only once on MOUSE_OVER each time the mouse is over that mc. On MOUSE_OUT nothing happens on the screen just the tween is being reset to play again.

In my set up it plays again

Link to comment
Share on other sites

v12: pass a time of 0 into the pause() method

 

 

 

 function outHandler_ACOLYTE_logo_btn(e:MouseEvent):void{
         ACOLYTE_flash_Tween.pause(0);
         trace("you rolled off me");
         }   
 

v11

 

function outHandler_ACOLYTE_logo_btn(e:MouseEvent):void{
         ACOLYTE_flash_Tween.currentTime = 0;
         ACOLYTE_flash_Tween.pause()
         trace("you rolled off me");
         }   
 

 

Link to comment
Share on other sites

It did not work. Maybe my Tween is too long, but at the end I have this ", repeat:1, yoyo:true, paused:true" Maybe it messes up what you are suggesting?

I attach  a simple file to take a look at.

Link to comment
Share on other sites

If you use restart() it will work, I'm not 100% sure why play() wasn't.

 

 

    function overHandler_ACOLYTE_logo_btn(e:MouseEvent):void{
         ACOLYTE_flash_Tween.restart();
         trace("you rolled over me");
         }
        
    function outHandler_ACOLYTE_logo_btn(e:MouseEvent):void{
         ACOLYTE_flash_Tween.currentTime = 0;//restarts the tween from 0
         ACOLYTE_flash_Tween.pause();//restarts the tween from 0
         trace("you rolled off me");
         } 
 
Link to comment
Share on other sites

restart() works perfectly every time.

I tested it without the set up in outHandler and it works as well.

If all I want the tween to play each time once the mouse is over my mc - do I need the set up in outHandler?

Link to comment
Share on other sites

The code in the outHandler was just to stop the tween immediately. It sounds like you don't need it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×