Jump to content
Search Community

restart with timeline lite AS2

Zync test
Moderator Tag

Recommended Posts

Hi ya,

 

I'm working on a quicker banner ad that needs to use AS2 but for some strange reason the restart isn't working as intended for me. Probably some nooby mistake I'm making but it seems OK code wise?

 

import com.greensock.TimelineLite;
import com.greensock.TweenLite;
/**
* ...
* @author Zync
*/
class cp720Banner extends MovieClip
{
public var coxPlateFeature:MovieClip;
public var theRace:MovieClip;
public var tattsCoxPlate:MovieClip;
public var sat23:MovieClip;
public var moonVal:MovieClip;
public var nova:MovieClip;
public var onSale:MovieClip;
public var logos:MovieClip;
public var tl:TimelineLite;

public function cp720Banner() 
{
	var nScreenTime:Number = 0.5;

	tl = new TimelineLite({onComplete:restartMe});

	tl.timeScale = 1;

	tl.addLabel("start", 0);

	tl.append(TweenLite.from(coxPlateFeature, 1, { _alpha:0, delay:nScreenTime } ));

	tl.append(TweenLite.from(theRace, 1, { _alpha:0 } ));
	tl.append(TweenLite.to(theRace, 1, { _alpha:0, delay:nScreenTime } ));

	tl.append(TweenLite.from(tattsCoxPlate, 1, { _alpha:0 } ));
	tl.append(TweenLite.to(tattsCoxPlate, 1, { _alpha:0, delay:nScreenTime } ));

	tl.append(TweenLite.from(sat23, 1, { _alpha:0 } ));
	tl.append(TweenLite.to(sat23, 1, { _alpha:0, delay:nScreenTime } ));

	tl.append(TweenLite.from(moonVal, 1, { _alpha:0 } ));
	tl.append(TweenLite.to(moonVal, 1, { _alpha:0, delay:nScreenTime } ));

	tl.append(TweenLite.from(nova, 1, { _alpha:0 } ));
	tl.append(TweenLite.to(nova, 1, { _alpha:0, delay:nScreenTime } ));

	tl.append(TweenLite.from(onSale, 1, { _alpha:0 } ));
	tl.append(TweenLite.to(onSale, 1, { _alpha:0, delay:nScreenTime+1 } ));

}

private function restartMe():Void
{
	tl.restart();
}


}

Link to comment
Share on other sites

Since it's AS2, I bet it's a scope issue - try adding onCompleteScope:this to the TimelineLite's vars parameter. This isn't necessary in AS3 because AS3 doesn't lose scope the way AS2 does.

 

It's tough to say what the problem is since you didn't describe what you meant by "not working as expected" - is nothing happening? Just certain tweens don't appear to work? Feel free to post a simple FLA that demonstrates the issue.

Link to comment
Share on other sites

Yeah it just doesn't restart the tween. The onComplete event fires fine but even with this.tl.restart() the timeline doesnt restart. Is that because the clip is already alpha'd at 0? Timelinemax doesnt seem to have this problem tho with the restart:-1 paramater

Link to comment
Share on other sites

Ah, sorry about that - I had changed something today that apparently the AS2 flavor didn't like - Flash evaluates a very particular condition differently in AS2 than it does in AS3 which is rather baffling, but I just posted a fix that works around it. Again, the bad AS2 version was only online for a few hours today and it looks like you snagged it within that window :) If you update to the latest version, you should be good to go. Sorry about the confusion.

Link to comment
Share on other sites

  • 2 weeks later...

Hmm ok seems like I got the same problem still. Downloaded the latest as2 versions of everything but still the timeline wont restart. In fact I cant even find the restart function in TimelineLite? Or am I just being a noob? :P

EDIT: Ah nvm that last bit, its in tween core huh. But yeah still nada on restart

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