Just for fun--- AS2 + AS3 TYPEWRITER EFFECT
Here's something I had to do today for client.
The idea is, you see the text type on "as if being typed on a typewriter".
I had to do it in As2 so heres the snippet ( I dont know if Posterous
supports formating so it might all just be jumbled together)
Its pretty strait forward so I wont go into any explaination, leave a
comment if you would like some. var s:String = "http:// www.thenameofareallygreatwebsite.com"; var i:Number = 0;
var interval:Number; myBtn.onRelease = startType; function startType ()
{
interval = setInterval(write,90); } function write () {
myText.text =s.substr(0,i) + "|"; if(i >= s.length){ myText.text =s;
clearInterval(interval);
} i++; } AS3 --------------------------------- var s:String = "http:// www.thenameofareallygreatwebsite.com";
var i:Number = 0;
var interval:Timer = new Timer(100, s.length+1);
interval.addEventListener("timer", write); myBtn.addEventListener(MouseEvent.CLICK, startType);
myBtn.buttonMode = true; function startType (e:MouseEvent):void
{
interval.start(); } function write (e:TimerEvent):void
{
myText.text =s.substr(0,i) + "|";
if(i >= s.length){ myText.text =s; }
i++; } Simple and fun! -happy coding!
(download)
(download)

