Waving Text Effect in Actionscript 3.0

var text:String       = "This text is a waving text";
var format:TextFormat = new TextFormat("Arial", 12);
var radius:int = 5;
var speed:Number = Math.PI/15;
var angle:Number =0
var letters:Array = null;


function Init():void
{
	letters = [];
	
	for (var a = 0, x = 0; a<text.length; a++)
	{
		letters[a] = new Sprite();
		
		var txt:TextField =  new TextField();
		txt.selectable = false;
		txt.autoSize = "left";
		txt.text = text.charAt(a);
		txt.setTextFormat(format);
		
		letters[a].addChild(txt);
		letters[a].x = a * 15;
		addChild(letters[a])
	}
	
	addEventListener(Event.ENTERFRAME, Animate, false, 0, true); 

}

function Animate(e:Event):void
{
	for (var a = 0; a<letters.length; a++) 
	{
		letters[a].y = Math.sin(angle+a)*radius;
	}
	
	angle += speed;
}

Init();
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s