View Full Version : macromedia tween class
jamiehill
02-06-2006, 06:31 PM
I'm currently using macromedias tween class to yoyo an mc backwards and forwards on the stage. Depending upon certain user interactions, the speed of this tween needs to change. Can you update the tween's speed whilst it is in action, or do I need to cancel that tween and start a new one with the updated speed?
Kevpool1
02-06-2006, 06:53 PM
Not sure whether it will work, but you could try to set the speed as a variable. Change the variable properties when a button is pressed for example.
var speed:Number = 5;
var ball:Tween = new Tween(ball_mc, "_x", Elastic.easeOut, 20, 100, speed, true);
button_mc.onRelease = function(){
do whatever...........
var speed:Number = 10;
}
As i said not sure whether this will work, new to AS but it's probably worth a try.
flashead
02-06-2006, 07:18 PM
kevpool1's got the right idea, just not quite right.
the tween class uses a property called _duration.
so you would reference that by using ball._duration;
var speed:Number = 5;
var ball:Tween = new Tween(ball_mc, "_x", Elastic.easeOut, 20, 100, speed, true);
ball._duration = 10;
just as a hint, you can use a for...in loop to trace anything in an object.
in your case you can use it to find all the properties of your new Tween instance named 'ball',
for instance, on the next line after you've created your 'ball' tween, add this:
for ( var i in ball ) trace( i + " = " + ball[i] );
it'll return all the other properties in the output window for you ;) (that's how i found out about the _duration, i didn't know you could change it like that until you asked)
k.
fx2ooo
07-05-2006, 11:03 AM
Know this is an old post, but would like to bring it up again. When I follow your hint for outputting the properties of and alpha tween, I get the following:
isPlaying = true
_startTime = 2067
_time = 0
broadcastMessage = [type Function]
_listeners = [Tween]
change = 15
func = [type Function]
useSeconds = true
_duration = 4
_pos = 15
prevPos = 15
begin = 15
prop = _alpha
obj = _level0.instance2.symSun_mc
First off, why does this not return ALL the properties, like finish? Second, does this output mean that it is possible to modify the begin value, but not the finish value? Isn't that strange?
mooska
07-05-2006, 11:16 AM
It does not list all the properties, couse some of them are declared with setter getter function set finish (f:Number):Void {
this.change = f - this.begin;
};
function get finish ():Number {
return this.begin + this.change;
};
but of course you can modify them.
fx2ooo
07-05-2006, 11:59 AM
Okay. But what about begin? If I try to change the value of begin, tween.begin += 10 for example, I get unreliable results. Sometimes it increases by 10, but other times it appears to multipy (not always by 10 either). Wish there was better documetation on the Tween class and all it's properties. According to the docs _duration is read only, and begin isn't even listed.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.