Jump to content
Search Community

TweenMax .kill();

Red_21 test
Moderator Tag

Recommended Posts


Hello everyone, I started to study TweenMax in AS3 environment.
I have 2 buttons, each button launches its animation.
When I press 1 button then animation 1 starts and it will work all the time even if I press 2 button.
Question: How can I stop animation when I call another animation?
Sorry for the English, I know him very badly.

 
[Embed(source = "image/anim1.png")] var Anim1:Class;
[Embed(source = "image/anim2.png")] var Anim2:Class;
var anim1 = new Anim1();
anim1.x = 1070;
anim1.y = 284;
anim1cont.addChild(anim1);
var anim2 = new Anim2();
anim2.x = 1070;
anim2.y = 284;
anim2cont.addChild(anim2);

cont.addChild(anim1cont);
cont.addChild(anim2cont);
addChild(cont);	

private function button1(event:MouseEvent):void { 
			removeEventListener(Event.ENTER_FRAME,  button1)
 			TweenMax.to(anim1cont, 6, {y:-10,x:-320, repeat:-1});
			}
private function botton2(event:MouseEvent):void
		{
			removeEventListener(Event.ENTER_FRAME,  button2)
 			TweenMax.to(anim2cont, 6, {y:-10,x:-320, repeat:-1});
		}

 

project1.rar

Link to comment
Share on other sites

Hi 

 

Unfortunately we don't offer much support of the AS3 tools these days but it sounds like you should be creating references to your tweens so you can play() and pause() them, something like:

 

var ani1 = TweenMax.to(anim1cont, 6, {y:-10,x:-320, repeat:-1, paused:true});

var ani2 = TweenMax.to(anim2cont, 6, {y:-10,x:-320, repeat:-1, paused:true});

private function button1(event:MouseEvent):void { 
			removeEventListener(Event.ENTER_FRAME,  button1)
 			ani1.play();
                        ani2.pause();
			}
private function botton2(event:MouseEvent):void
		{
			removeEventListener(Event.ENTER_FRAME,  button2)
ani2.play();
ani1.pause();
 			
		}
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.
×
×
  • Create New...