Animating text fields with Actionscript
March 11th, 2009
Well after a little period of no posts due to being insanely busy, I thought I would share a little technique I discovered through trial and error and a little thought. Ever wanted to tween individual letters from a text field with AS3 rather than on the time line in flash? Well it is incredibly easy!
Firstly you need to create your text in the Flash authoring tool, and then after adding the text field to a container MovieClip or Sprite you simply break it apart once so that the text is separated.
Once this is done either on the main timeline or in your document class you can target the texts by targeting the container sprite's children with getChildAt(); during a for loop:
-
function startAnim():void
-
{
-
for(var j:uint = 0; j <textHolder.numChildren; j++){
-
obArray[j] = textHolder.getChildAt(j);
-
}
-
for(var i:uint = 0; i <obArray.length; i++){
-
holderArray[i] = new MovieClip();
-
addChild(holderArray[i]);
-
holderArray[i].addChild(obArray[i]);
-
holderArray[i].z = -5000;
-
holderArray[i].x = 1068;
-
holderArray[i].y = 68;
-
holderArray[i].filters = [blur, drop];
-
}
-
}
You can then add the children to their own individual container sprite as you can see and then target that sprite in order to transform any property, including filters and its stage position.
-
function next(e:TimerEvent):void
-
{
-
timer.stop();
-
timer.removeEventListener(TimerEvent.TIMER, next);
-
addEventListener(Event.ENTER_FRAME, loop);
-
for(var i:uint = 0; i <holderArray.length; i++){
-
var delayTime:Number = Math.random()*4;
-
var tween1:GTween = new GTween(holderArray[i], .8,{y: -500,
-
delay: delayTime},{ease:Bounce.easeOut});
-
}
-
timer = new Timer(4000, 0);
-
timer.addEventListener(TimerEvent.TIMER, init);
-
timer.start();
-
}
Cue another spate of crappy banner ads.......!!!
Get the source here.
Categories: Actionscript 3.0, Text | Tags: Actionscript 3.0, Experiments, text effect




































![Validate my RSS feed [Valid RSS]](http://www.ultravisual.co.uk/blog/images/valid-rss.png)





[...] http://ultravisual.co.uk/blog/2009/03/11/animating-text-fields-with-actionscript/ [...]