Sunday, July 12, 2009
Thursday, July 9, 2009
Creating Dynamic Tween Variables In a Timed Sequence
Say you want to have a number of tweens perform in a sequence but you don't want to type out all the tweens. Here is how you do it using a timer to animate some menus one at a time with a delay of 50 milliseconds between each:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var timerCounter:uint=0;
var theTimer:Timer=new Timer(50,6);/
theTimer.start();
theTimer.addEventListener(TimerEvent.TIMER, display);
function display(e:TimerEvent):void {
timerCounter++;
var thisLoopNode:Object=menu_mc.getChildByName("node"+timerCounter);
this["tweenx"+timerCounter]=new Tween(thisLoopNode,"x",Regular.easeOut,0,100,1,true);
this["tweeny"+timerCounter]=new Tween(thisLoopNode,"y",Regular.easeOut,0,timerCounter*10,1,true);
this["tweenalpha"+timerCounter]=new Tween(thisLoopNode,"alpha",Regular.easeOut,0,1,1,true);
}
Loading external images and reacting to load complete and smoothing bitmap
var slideLoader:Loader=new Loader();
csHostRef.addChild(slideLoader);
slideLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, slidePreloaded);
slideLoader.load(new URLRequest(xml.slide[currentSlide].mediaURL));
function slidePreloaded(){
//do stuff here now that pict has loaded
//...and this will smooth the bitmap so it doesnt look crappy scaling
var smoother_bm=Bitmap(slideLoader.content);
smoother_bm.smoothing=true;
}
Subscribe to:
Posts (Atom)