Jump to content
Search Community

How do I move to the next frame after timeLineMax stopped playing?

ngrinchenko test
Moderator Tag

Recommended Posts

I have a small animation playing on frame 1 in my main time line of the flash file. How would I write the function that once the time line Max animation completed playing the website moves to frame 2 in my main time line of the flash file?

 

Here is what I was able to come up with:

 

import com.greensock.*;
import com.greensock.easing.*;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
openingImage_timeLine.addEventListener(TweenEvent.COMPLETE, goToNextFrame);
function goToNextFrame(e:TweenEvent):void{
gotoAndPlay(2);
	 }

 

I am not sure if I need:

import fl.transitions.Tween;
import fl.transitions.TweenEvent;

 

the error code I am getting is

Symbol 'mainsite_mc', Layer 'AS3', Frame 1, Line 32 1119: Access of possibly undefined property COMPLETE through a reference with static type Class.
Link to comment
Share on other sites

A follow up question. I would like to make it work with the code you have suggested for the better performance, with an onComplete callback

var openingImage_timeLine = new TimelineMax({onComplete:goToNextFrame});

However I am not able to make it work. I am able to make it work this way:

openingImage_timeLine.addEventListener(TweenEvent.COMPLETE, goToNextFrame);
function goToNextFrame(e:TweenEvent):void{
gotoAndPlay(2);
	 }

 

I am attaching a simplified version of my file. Please take a look why it doesn't work in my case?

Link to comment
Share on other sites

Thanks, it seems to work. Now my code looks like this:

var openingImage_timeLine:TimelineMax = new TimelineMax({timeScale: 1.5, onComplete:gotoAndPlay("contactus")});

 

"contactus" is a label on the main time frame

 

Actually, I don't think that will work. If you do

 

"onComplete:gotoAndPlay(2)"

 

gotoAndPlay(2) will execute immediately.

 

You have a few options

 

OPTION1: call gotoAndPlay directly and pass in onCompleteParams

var openingImage_timeLine = new TimelineMax({onComplete:gotoAndPlay, onCompleteParams:[2]});

 

OPTION2: Call your own function and hardcode in the frame number

var openingImage_timeLine = new TimelineMax({onComplete:goToNextFrame });

function goToNextFrame():void{
gotoAndPlay(2);
}

 

OPTION3: call your own function and pass in any value representing which frame to go to

var openingImage_timeLine = new TimelineMax({onComplete:goToNextFrame, onCompleteParams:[2]});

function gotoNextFrame(frame):void{
    gotoAndPlay(frame);
}

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