Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
heyitsjayy

gotoAndPlay new tween function on return to frame with label

Recommended Posts

Hello guys!

 

Wondering if anyone might be able to share some insight on this, if anyone's done something similar.

 

On one frame there is a timelinelite animation that plays automatically. I was thinking to put this in a function called firstAnimation() for one purpose.

Reason being is that when on this frame, the flash stage is rolledover it goes to another, separate frame with no greensock.

 

Now when it advances to that different frame, there is a stage RollOff function which returns it to that previous frame with the greensock timeline lite animation. Instead of playing this original animation though, I was looking for a way to play a new greensock animation, secondAnimation(), if you will.

 

Either that, or does anyone know how to just have a timelinelite play once ONLY. Then be ignored the rest of the time.. even if this frame is exited, then returned to. Basically clear that first animation after running, and having new MCs/greensock animation appear in its place the rest of the time,

Link to comment
Share on other sites

Hi,

 

I would have to recommend that you don't jump back and forth between frames. It is recommended that you keep all your code and assets on 1 frame. The problem with putting code on frame1, jumping to frame X and then back to frame1 is that the code on frame is going to execute again.

 

You could wrap everything in a conditional statement on frame 1 so that only certain things happen the first time you are on frame 1:

 

1) create a new fla

2) put this code on frame 1

 

 

var hasPlayed:Boolean;
if (! hasPlayed) {
trace("first time on frame 1");
hasPlayed = true;
gotoAndStop(5);
} else {
trace("second time of frame 1");
}

 

3) add a keyframe on frame 5

4) place this code on frame 5

 

trace("welcome to frame 5");
gotoAndStop(1);

5)test movie

6)produce this result:

 

first time on frame 1

welcome to frame 5

second time of frame 1

 

And yes if you want to remove everything from your TimelineLite you can use an onComplete callback function to clear the timeline like so

 

myTimeline.clear();

 

Hope this helps, but really should try to do as much as you an in a single frame. Using this technique, you would hide certain elements on your rollover and show other elements something like

 

function rollOverHandler(e:MouseEvent):void{
intro_mc.visible = false //or use a TweenLite autoAlpha tween
frame2_assets.visible = true;
}

Link to comment
Share on other sites

Thanks!, and yes agreed. Normally don't use different keyframes, though this was using a template & didn't create that :)

 

Anyway the "intro_mc.visible = false, & frame2_assets = true" part, helped out with one part of it.

 

I wonder if there's another special greensock method out there that will unload a timelineLite, even before it finishes completely. The reason being that sometimes the timeline won't always complete before a user jumps to another frame. And when going back to that frame the timelineLite is set to start automatically. Is there something similar like 'onComplete' that says instead something like 'if run once and didn't complete (or even if it did), don't play it ever again no matter what!!" haha. Open to suggestions on that. Thinking onInit() and onstart() could be used in some way to count if it started once.

 

Was thinking a combination of the above code like this could work. Will give it a shot.

var timelinelitehasPlayed:Boolean;

if (! timelinelitehasPlayed) {

trace("timelinelite started once");

timelinelitehasPlayed = true;

myTimelinelite.clear();

} else {

secondAnimation();

trace("second fucntion which includes some greensock anim plays");

}

 

 

Update:

This thread of some of your code gave me some good ideas :ugeek:

http://forums.greens...start-problems/

 

 

Actually, I figured this out a different way, by just including the 2nd animation/MC graphics & code on that separate frame. Kinda thought about it too much & made it way too difficult than it needed. Though I learned a lot more about greensock, and some new methods in the process. 8-) Thanks again for your help.

Link to comment
Share on other sites

Glad to hear you got it worked out on your own. Sounds like you you're doing real well. Keep up the great work.

 

-c

  • Like 1
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.
×