Yes, there are apparently multiple Tween classes in Flash 8 (and maybe MX 2004 -- I didn't check that). The one I've most often seen used is mx.transitions.Tween, not the one in mx.effects that you imported. Here is an example of your code (except I used 21 fps instead of 61 so I wouldn't have to paste 60 lines of output) used with that class. onMotionFinished does report when it's done, and there's also a onMotionChanged that apparently reports once per frame. Here is the frame-based code and output:

import mx.transitions.Tween;
import mx.transitions.easing.*;

function myTweenFunc(){
var tw:Tween = new Tween(myMC,"_x", Regular.easeInOut, -310, 20, 10, false);
   tw.FPS = 21;
   tw.onMotionFinished=function(){
           trace('finished moving lance');
   }
// the time property appears to actually be frame count for frame-based tweens
   tw.onMotionChanged = function() {
       trace('changed, time='+this.time+' prevPos='+this.prevPos);
   }
}
myTweenFunc();

changed, time=1 prevPos=-310
changed, time=2 prevPos=-303.4
changed, time=3 prevPos=-283.6
changed, time=4 prevPos=-250.6
changed, time=5 prevPos=-204.4
changed, time=6 prevPos=-145
changed, time=7 prevPos=-85.6
changed, time=8 prevPos=-39.4
changed, time=9 prevPos=-6.39999999999998
changed, time=10 prevPos=13.4
finished moving lance

and this is the change to the tween line and output for a time-based tween (tween dur=1 second, 20 fps movie)

var tw:Tween = new Tween(myMC,"_x", Regular.easeInOut, -310, 20, 1, true);

changed, time=0.055 prevPos=-310
changed, time=0.109 prevPos=-306.9145
changed, time=0.158 prevPos=-297.88138
changed, time=0.206 prevPos=-284.53672
changed, time=0.259 prevPos=-266.71528
changed, time=0.311 prevPos=-241.57738
changed, time=0.362 prevPos=-211.34458
changed, time=0.414 prevPos=-176.33512
changed, time=0.465 prevPos=-135.17608
changed, time=0.517 prevPos=-89.4505
changed, time=0.567 prevPos=-37.95478
changed, time=0.619 prevPos=8.76121999999998
changed, time=0.671 prevPos=51.93578
changed, time=0.722 prevPos=89.59418
changed, time=0.773 prevPos=121.17032
changed, time=0.824 prevPos=147.44042
changed, time=0.876 prevPos=168.40448
changed, time=0.928 prevPos=184.31648
changed, time=0.989 prevPos=194.71232
changed, time=1 prevPos=199.87658
finished moving lance

Helen

--
http://flash-creations.com
http://i-technica.com


[EMAIL PROTECTED] wrote:

Hi
having some difficulty getting the handlers working with the built-in Tween 
class

also, does the Tween class actually exist in more than one place?


//CODE START

import mx.effects.*;
import mx.transitions.easing.*;

function myTweenFunc(){

        myMC.onTweenUpdate = function(value) {
                this._x = value;
        }

                        
        var tw = new Tween(myMC,-310, 20, 500,false);
        tw.easingEquation = Regular.easeInOut;
        tw.FPS=61;

        //the following handler doesn't work!!!!
       tw.onMotionFinished=function(){
        trace('finished moving lance');
        }

}
myTweenFunc();

//CODE END


Any suggestions?
Thanks in advance
Jim bachalo

[e] jbach at bitstream.ca
[c] 416.668.0034
[w] www.bitstream.ca
--------------------------------------------
"...all improvisation is life in search of a style."
            - Bruce Mau,'LifeStyle'



_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to