Jump to content
Search Community

onComplete triggers at start of my timeline [SOLVED]

manor test
Moderator Tag

Recommended Posts

When I run the code below the function I call with the onComplete parameter plays at the start of my timeline not on completion. Any ideas?

 

...

function play_b1():void{
	mask_mc.alpha = 1;
	b1art.alpha = 1;
	mask_mc.play();
}


function b1_fn (Event:MouseEvent):void{
var b1_tl:TimelineMax = new TimelineMax({onComplete:play_b1()});
b1_tl.insert(TweenMax.to(b1, .5, {x:274.55, y:200, delay:.5, ease:Linear.easeNone}));

...

Link to comment
Share on other sites

I get the same result adding the onComplete to the TweenMax.to. To clarify I have the timline linked to a MOUSE_DOWN event. I am not sure if that makes a difference, but I included the listener at the top of my code snippet.

b1.addEventListener(MouseEvent.MOUSE_DOWN, b1_fn);

function play_b1():void{
	mask_mc.alpha = 1;
	b1art.alpha = 1;
	mask_mc.play();
}


function b1_fn (Event:MouseEvent):void{
var b1_tl:TimelineMax = new TimelineMax();
b1_tl.insert(TweenMax.to(b1, .5, {x:274.55, y:200, delay:.5, ease:Linear.easeNone, onComplete:play_b1()}));

Link to comment
Share on other sites

This issue is solved... I needed leave the "()" off the function call:

 

 

b1.addEventListener(MouseEvent.MOUSE_DOWN, b1_fn);

function play_b1():void{
	mask_mc.alpha = 1;
	b1art.alpha = 1;
	mask_mc.play();
}


function b1_fn (Event:MouseEvent):void{
var b1_tl:TimelineMax = new TimelineMax();
b1_tl.insert(TweenMax.to(b1, .5, {x:274.55, y:200, delay:.5, ease:Linear.easeNone, onComplete:play_b1}));

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...