Jump to content
Search Community

Problem with addCallback

pixelbeat test
Moderator Tag

Recommended Posts

I got this menu, that triggers a function called closeAndPlay(), basically closes an array of pictures and then calls the function gotoAndStop, but it's not working.

 


function hitButton (e:Event){
closeAndPlay(5);
}

function closeAndPlay(setFrame:Number):void {
trace(setFrame)
var closePictures:TimelineMax=new TimelineMax({paused:true});
closePictures.insertMultiple( TweenMax.allTo(pictures, 2.5, {alpha:0, ease:Quart.easeInOut}, 0), 0.5);
closePictures.addCallback(gotoAndStop, setFrame);
closePictures.play();
}

 

What I am doing wrong?

 

Cheers to everyone and thanks for your help.

D.

Link to comment
Share on other sites

Fixed & working!

 

function closeAndPlay(setFrame:Number):void {
  var closePictures:TimelineMax=new TimelineMax({paused:true,  onComplete:gotoAndStop, onCompleteParams:[setFrame]});
  closePictures.insertMultiple( TweenMax.allTo(pictures, 2.5, {alpha:0, ease:Quart.easeInOut}, 0), 0.5);
  closePictures.play();
  }

Link to comment
Share on other sites

Glad you got it working. For the record, you were just defining the addCallback() parameters incorrectly. See the ASDocs for more details, but basically the second parameter is the time at which you want to insert the callback, and the 3rd parameter is an array of parameters that you want passed to the callback (if any). So yours would look like:

 

closePictures.addCallback(this.gotoAndStop, closePictures.duration, [setFrame]);

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