Jump to content
Search Community

sequencing a set of distribute to path objects

spycatcher2011 test
Moderator Tag

Recommended Posts

Hello all thanks for your time

I am trying to sequence a group of path following tweens one after the other ,and control the speed of the sequence.

Example i have three tweens.

 

 

var myTween1:TweenMax = new TweenMax(path1, 5, {progress:1, repeat:-1, ease:Linear.easeNone});

///play next 1sec later

var myTween2:TweenMax = new TweenMax(path2, 5, {progress:1, repeat:-1, ease:Linear.easeNone});

////play next 1sec later

var myTween3:TweenMax = new TweenMax(path3, 10, {progress:1, repeat:-1, ease:Linear.easeNone})

 

I would like to add play delay between each tween that is adjustable.

I have tried to put each tween into and array and use a timer

as bellow

var b:Number

b=-1

//// create array of tweens

var tween1:Array=new Array();

tween1=[myTween1,myTween2,myTween3];

 

button1_btn.addEventListener(MouseEvent.CLICK,change1);

function change1 (e:MouseEvent){

var timerTween:Timer = new Timer(1000, 3);

timerTween.addEventListener(TimerEvent.TIMER, timerHandler);

timerTween.start();

function timerHandler(eventObject:TimerEvent):void {

 

b++

tween1.play();

trace(B);

 

}

 

 

};

 

but i get a null object error,is there any way to do this or is something simple i have missed ?

As the tweens do not stop I cant use the on complete function.

 

at flash.utils::Timer/tick()

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at MethodInfo-329()

at flash.utils::Timer/_timerDispatch()

at flash.utils::Timer/tick()

 

 

Best Regards

Peter

Link to comment
Share on other sites

Hi Peter,

 

The best way to sequence tweens would be to use TimelineLite/Max. http://www.greensock.com/timelinemax

 

the code would look like this:

 

var myTween1:TweenMax = new TweenMax(path1, 5, {progress:1, repeat:-1, ease:Linear.easeNone});
var myTween2:TweenMax = new TweenMax(path2, 5, {progress:1, repeat:-1, ease:Linear.easeNone});
var myTween3:TweenMax = new TweenMax(path3, 10, {progress:1, repeat:-1, ease:Linear.easeNone})

//create a TimelineLite and pause it.
var tl:TimelineLite = new TimelineLite({paused:true})
tl.append(myTween1);
tl.append(myTween2, 1) // 1 second delay after myTween1 finishes
tl.append(myTween3, 1) // 1 second delay after myTween2 finishes

//you could also use appendMultiple() but the above syntax is easier to get started with.

 

inside your button function you would tell the sequence to play with

 

tl.play()

 

That being said, the only thing I noticed that looked funny was that your tweens weren't paused, so I wonder why they are not playing immediately when you create them. I was expecting to see:

var myTween1:TweenMax = new TweenMax(path1, 5, {progress:1, repeat:-1, ease:Linear.easeNone, paused:true});

 

also, as a general best practice it would be better not to have your timer function inside the MouseEvent function.

 

all that being said, i really don't see why your code isn't working unless there is something wrong with how your tweens are being constructed. Will your tweens work if you take out all the timer and array code?

 

from what I can tell:

 

your tweens are in the array

your timer fires 3 times

your code for targeting the tweens in the array and telling them to play looks good

 

if you want to zip up a simple fla, I can take it a look at it.

Link to comment
Share on other sites

Dear Carl

Thanks for your help ,I tried the sequencing code and I got this error

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at com.greensock::TimelineLite/insert()

at com.greensock::TimelineLite/append()

at acmtyp3a_fla::MainTimeline/frame1()

I also tried to put the code inside the button handler but the result was the same.

////////////////

As per your suggestion ,I removed the timer from the button event ,but I still get an error message.

var tween1:Array=new Array();
tween1=["myTween","myTween1","myTween2"];
var b:Number		
b=-1var
timerTween:Timer = new Timer(100, 3);
timerTween.addEventListener(TimerEvent.TIMER, timerHandler);
function timerHandler(e:TimerEvent):void {
	b++
	tween1[b].play();
			trace(;
}

button1_btn.addEventListener(MouseEvent.CLICK,change1);
function change1 (e:MouseEvent){
timerTween.start();
}

///////////////

Error Message

TypeError: Error #1006: value is not a function.

at acmtyp3a_fla::MainTimeline/timerHandler()

at flash.utils::Timer/_timerDispatch()

at flash.utils::Timer/tick()

TypeError: Error #1006: value is not a function.

at acmtyp3a_fla::MainTimeline/timerHandler()

at flash.utils::Timer/_timerDispatch()

at flash.utils::Timer/tick()

TypeError: Error #1006: value is not a function.

at acmtyp3a_fla::MainTimeline/timerHandler()

at flash.utils::Timer/_timerDispatch()

at flash.utils::Timer/tick()

as soon as press the button.

 

I am sorry ,I forgot to add to the code that I have a "pause all" function to stop all the tweens, and each tween is inside a movie clip

so I can control the Alpha of the tween.

If i remove the code "tween1.play();" within the button statement the trace works okay giving me 0,1,2.

Thanks again peter

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