Jump to content


sequential tweening?


  • You cannot reply to this topic
6 replies to this topic

#1 boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 12 March 2007 - 09:33 PM

G'day all,

Hoping someone can help me with this! I'm trying to get an mc to tween a certain way, then tween another way, using actionscript.

Here's what I've got so far:

stop();
#include "lmc_tween.as"
sun_mc.tween("_y",195,25,"easeOutSine",5);
sun_mc.brightOffsetTo(75,15,"linear",15);
moon_mc.tween("_x",225,25,"easeOutSine",5);
moon_mc.brightOffsetTo(-65,15,"linear",15);

Once the above mcs have finished tweening, I want them to do this:

sun_mc.tween("_y",325,25,"easeInSine",0);
sun_mc.brightOffsetTo(0,15,"linear",15);
moon_mc.tween("_x",100,25,"easeInSine",0);
moon_mc.brightOffsetTo(0,15,"linear",15);

...or something similar. In other words, I've got a sun and a moon - I want them to converge (creating an eclipse), and then continue moving. The reason I want to do 2 separate tweens for the movement is that I want them to slow down into the eclipse, and then speed up out of it - that can't be done in a single tween, right? Same applies for the brightness - I want the moon (for example) to get darker as it eclipses, and then brighter as it moves away.

Hope I've been clear enough - any help would be much appreciated! I'm trying to do all this stuff in Actionscript, rather than timeline motion tweens.

Cheers in advance!

boog :whoosh[1]:

#2 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 13 March 2007 - 07:40 AM

You can use the onMotionFinished method with the tween class. Try the following code:

var oTweenListener:Object = new Object();
oTweenListener.onMotionFinished = function(){
	// do the next tween here.
	var tweeny:Tween = new Tween(blah blah blah);
	tweeny.addListener(oTweenListener2);
	
	var oTweenListener2:Object = new Object();
		oTweenListener.onMotionFinished = function(){
		// do the next tween here.
	}
}
var tweeny:Tween = new Tween(blah blah lbah);
tweeny.addListener(oTweenListener);

You may need to pass scope into the objects, because when the onMotionFinished is called, they lose scope. so just do:

oTweenListener._target = // my target movieclip to tween

#3 boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 15 March 2007 - 01:08 AM

I don't really get what you mean, sorry!

Can you use my above actionscript in yours...?

Cheers!

Boog :rolleyes:

#4 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 15 March 2007 - 07:47 AM

stop();
#include "lmc_tween.as"

// delete these import lines if you have them elsewhere.
import mx.transitions.Tween;
import mx.transitions.easing.*;
//

var sunTween:Tween = new Tween(sun_mc, "_y",195,25,"easeOutSine",5);
sun_mc.brightOffsetTo(75,15,"linear",15);
var moonTween:Tween = new Tween(moon_mc, "_x",225,25,"easeOutSine",5);
moon_mc.brightOffsetTo(-65,15,"linear",15);

var oListener:Object = new Ojbect();
oListener.sun = sun_mc;
oListener.moon = moon_mc;

oListener.onMotionFinished = function(){
var sunTween:Tween = new Tween(this.sun, "_y",325,25,"easeInSine",0);
this.sun.brightOffsetTo(0,15,"linear",15);
var moonTween:Tween = new Tween(this.moon, "_x",100,25,"easeInSine",0);
this.moon.brightOffsetTo(0,15,"linear",15);
}
sunTween.addListener(oListener);


#5 boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 27 March 2007 - 08:54 AM

G'day mate,

Thanks heaps for your help - I've ended up using Fuse, which is doing the trick nicely!

:D

#6 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 27 March 2007 - 03:42 PM

Good call there mate. Fuse is much, much better.

#7 boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 30 March 2007 - 08:36 AM

Yes, it seems very lovely so far :P:);)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users