/************************************************************************************** Program: ComboTween Version: 0.5 Author : Petit Publications http://petitpub.com Usage : This Actionscript 2.0 should be included in the first frame of the *.fla file to run the show. Purpose: To test the Tween class in tweening the scale and transparency of a JPG image. **************************************************************************************/ // Import the Tween class and the easing package import mx.transitions.Tween; import mx.transitions.easing.*; // Global variables var mc:MovieClip; // The movieclip used as a holder for the image var scaleFrom = 40; // Start with a scale value of 40% var alphaStart = 20; // Start with an alpha value of 20% // create a movieclip to load the photo into function getImage(){ mc = _root.createEmptyMovieClip("photo", i); // position the clip mc._x = 1; mc._y = 1; // create a movieclip so that our onPress isn't overwritten by the jpg mc.createEmptyMovieClip("jpgHolder", 1); // and load the jpeg into it mc.jpgHolder.loadMovie("images/petit.jpg"); // Default start value for alpha mc._alpha = alphaStart; // Default value for scale mc._xscale = scaleFrom; mc._yscale = scaleFrom; // add the onPress handler to the movieclip mc.onPress = doTween; } // Do the combination tween on the MovieClip function doTween(){ // trace(mc._alpha); // check for access // mc._alpha = 20; // works nicely var mcXScale:Tween = new Tween(mc, "_xscale", Regular.easeIn, scaleFrom, 100, 2, true); var mcYScale:Tween = new Tween(mc, "_yscale", Regular.easeIn, scaleFrom, 100, 2, true); var mcAlpha:Tween = new Tween(mc, "_alpha" , Strong.easeIn, alphaStart, 100, 2, true); // A finished tween event handler /*mcAlpha.onMotionFinished = function(){ // This does't work mcAlpha.rewind(); }*/ // Let's try a "class property" that works: mcAlpha["onMotionFinished"] = function(){ // The handler is not an instance property. mcXScale.rewind(); mcYScale.rewind(); mcAlpha.rewind(); } }; function main(){ getImage(); }