I am new to actionscript 3. I have text appearing in a text field with the appearence of a typewriter effect. How do I write the code so that present text after a 3 second delay is replaced by new text?
use a timer. i assume you have a function (eg, twEffectF) or class that accepts the text you want displayed with that effect and accepts the textfield (eg, tf) where you want that displayed. if so, use:
var textA:Array=["first string to display","next string","last string"] ;
var t:Timer=new Timer(3000,0);
t.addEventListener(TimerEvent.TIMER,timerF);
t.start();
function timerF(e:TimerEvent):void{
tsEffectF(tf,textA[(Timer(e.currentTarget).repeatCount-1)%textA.length ]);
}
Thanks for the quick response. This is the code I have so far var myString:String = "You cannot stop a Tornado."; var myArray:Array = myString.split("");
addEventListener(Event.ENTER_FRAME,frameHandler);
function frameHandler(event:Event):void{
if(myArray.length > 0) {
textField.appendText(myArray.shift());
}
else
{
removeEventListener(Event.ENTER_FRAME, frameHandler);
textField.text="";
}
}
Date: Sat, 14 Apr 2012 10:40:27 -0600
From: forums@adobe.com
Subject: Re: New to Actionscript 3 New to Actionscript 3
Re: New to Actionscript 3
created by kglad in Flash Pro - General - View the full discussion
use a timer. i assume you have a function (eg, twEffectF) or class that accepts the text you want displayed with that effect and accepts the textfield (eg, tf) where you want that displayed. if so, use: var textA:Array=["first string to display","next string", "last string"];var t:Timer=new Timer(3000,0);t.addEventListener(TimerEvent.TIMER,timerF);t.start(); function timerF(e:TimerEvent):void{tsEffectF(tf,textA[Timer(e.currentTarget).r epeatCount%textA.length]);}
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Re: New to Actionscript 3
To unsubscribe from this thread, please visit the message page at Re: New to Actionscript 3. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Flash Pro - General by email or at Adobe Forums
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.
Oh and more important than the timer I would like to know what code I need to add so that I can replace the typewriter effect text with new text after a 3 second delay. Thanks for all your help! rleach
Date: Sat, 14 Apr 2012 10:40:27 -0600
From: forums@adobe.com
Subject: Re: New to Actionscript 3 New to Actionscript 3
Re: New to Actionscript 3
created by kglad in Flash Pro - General - View the full discussion
use a timer. i assume you have a function (eg, twEffectF) or class that accepts the text you want displayed with that effect and accepts the textfield (eg, tf) where you want that displayed. if so, use: var textA:Array=["first string to display","next string", "last string"];var t:Timer=new Timer(3000,0);t.addEventListener(TimerEvent.TIMER,timerF);t.start(); function timerF(e:TimerEvent):void{tsEffectF(tf,textA[Timer(e.currentTarget).r epeatCount%textA.length]);}
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Re: New to Actionscript 3
To unsubscribe from this thread, please visit the message page at Re: New to Actionscript 3. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Flash Pro - General by email or at Adobe Forums
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.
use:
var textA:Array=["first string to display","next string","last string"] ;
var t:Timer=new Timer(3000,0);
t.addEventListener(TimerEvent.TIMER,timerF);
t.start();
function timerF(e:TimerEvent):void{
twEffectF(textA[(Timer(e.currentTarget).repeatCount-1)%textA.length ]);
}
function twEffect(s:String):void{
textField.text="";
this.myArray=s.split("");
addEventListener(Event.ENTER_FRAME,frameHandler);
}
function frameHandler(event:Event):void{
if(myArray.length > 0) {
textField.appendText(myArray.shift());
}
else
{
removeEventListener(Event.ENTER_FRAME, frameHandler);
textField.text="";
}
}
Hey thanks again for all your help. Unfortunately the code you sent does not work. I think its the twEffect (I assume you mean typewriter effect) that is in the code that is causing the problem. Here is the original code that works which types out the one line of text "You cannot stop a Tornado."
var myString:String = "You cannot stop a Tornado.";
var myArray:Array = myString.split(""); //seperates each letter which creates the typewriter effect.
addEventListener(Event.ENTER_FRAME,frameHandler);
function frameHandler(event:Event):void{
if(myArray.length > 0) {
textField.appendText(myArray.shift());
}
else
{
removeEventListener(Event.ENTER_FRAME, frameHandler);
textField.text="";
}
}
Date: Sat, 14 Apr 2012 16:11:25 -0600
From: forums@adobe.com
Subject: Re: New to Actionscript 3 New to Actionscript 3
Re: New to Actionscript 3
created by kglad in Flash Pro - General - View the full discussion
use: var textA:Array=["first string to display","next string","last string"] ;var t:Timer=new Timer(3000,0);t.addEventListener(TimerEvent.TIMER,timerF);t.start(); function timerF(e:TimerEvent):void{twEffectF(textA[(Timer(e.currentTarget).rep eatCount-1)%textA.length ]);}function twEffect(s:String):void{textField.text="";this.myArray=s.split("");ad dEventListener(Event.ENTER_FRAME,frameHandler);} function frameHandler(event:Event):void{ if(myArray.length > 0) { textField.appendText(myArray.shift()); } else { removeEventListener(Event.ENTER_FRAME, frameHandler); textField.text=""; } }
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Re: New to Actionscript 3
To unsubscribe from this thread, please visit the message page at Re: New to Actionscript 3. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Flash Pro - General by email or at Adobe Forums
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.
use:
var textA:Array=["first string to display","next string","last string"];
var myArray:Array = [];
var t:Timer=new Timer(3000,0);
t.addEventListener(TimerEvent.TIMER,timerF);
t.start();
function timerF(e:TimerEvent):void {
twEffectF(textA[(Timer(e.currentTarget).currentCount-1)%textA.length ]);
}
function twEffectF(s:String):void {
trace(1,s,2)
textField.text="";
myArray=s.split("");
addEventListener(Event.ENTER_FRAME,frameHandler);
}
function frameHandler(event:Event):void {
if (myArray.length>0) {
textField.appendText(myArray.shift());
} else {
removeEventListener(Event.ENTER_FRAME, frameHandler);
textField.text="";
}
}
p.s. please mark helpful/correct responses, if there are any.
Hey, Thanks a lot! it works. rleach
Date: Sun, 15 Apr 2012 08:26:55 -0600
From: forums@adobe.com
Subject: Re: New to Actionscript 3 New to Actionscript 3
Re: New to Actionscript 3
created by kglad in Flash Pro - General - View the full discussion
use: var textA:Array=["first string to display","next string","last string"];var myArray:Array = [];var t:Timer=new Timer(3000,0);t.addEventListener(TimerEvent.TIMER,timerF);t.start(); function timerF(e:TimerEvent):void { trace(textA[(Timer(e.currentTarget).currentCount-1)%textA.length ]) twEffectF(textA[(Timer(e.currentTarget).currentCount-1)%textA.length ]);}function twEffectF(s:String):void { trace(1,s,2) textField.text=""; myArray=s.split(""); addEventListener(Event.ENTER_FRAME,frameHandler);} function frameHandler(event:Event):void { if (myArray.length>0) { textField.appendText(myArray.shift()); } else { removeEventListener(Event.ENTER_FRAME, frameHandler); textField.text=""; }} p.s. please mark helpful/correct responses, if there are any.
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Re: New to Actionscript 3
To unsubscribe from this thread, please visit the message page at Re: New to Actionscript 3. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Flash Pro - General by email or at Adobe Forums
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.
here is another problem I incountered which I thought I would be able so solve easily. After the string plays through ( last set of text) it loops. How do I get it to play once and stop. I tried a couple of ways. I tried a stop function and the I tried adding a complete addEventListiner. I could not get it to work. Again, thanks for all your help! rleach
Date: Sun, 15 Apr 2012 08:26:55 -0600
From: forums@adobe.com
Subject: Re: New to Actionscript 3 New to Actionscript 3
Re: New to Actionscript 3
created by kglad in Flash Pro - General - View the full discussion
use: var textA:Array=["first string to display","next string","last string"];var myArray:Array = [];var t:Timer=new Timer(3000,0);t.addEventListener(TimerEvent.TIMER,timerF);t.start(); function timerF(e:TimerEvent):void { trace(textA[(Timer(e.currentTarget).currentCount-1)%textA.length ]) twEffectF(textA[(Timer(e.currentTarget).currentCount-1)%textA.length ]);}function twEffectF(s:String):void { trace(1,s,2) textField.text=""; myArray=s.split(""); addEventListener(Event.ENTER_FRAME,frameHandler);} function frameHandler(event:Event):void { if (myArray.length>0) { textField.appendText(myArray.shift()); } else { removeEventListener(Event.ENTER_FRAME, frameHandler); textField.text=""; }} p.s. please mark helpful/correct responses, if there are any.
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Re: New to Actionscript 3
To unsubscribe from this thread, please visit the message page at Re: New to Actionscript 3. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Flash Pro - General by email or at Adobe Forums
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.
use:
var textA:Array=["first string to display","next string","last string"];
var myArray:Array = [];
var t:Timer=new Timer(3000,textA.length);
t.addEventListener(TimerEvent.TIMER,timerF);
t.start();
function timerF(e:TimerEvent):void {
twEffectF(textA[(Timer(e.currentTarget).currentCount-1)%textA.length ]);
}
function twEffectF(s:String):void {
trace(1,s,2)
textField.text="";
myArray=s.split("");
addEventListener(Event.ENTER_FRAME,frameHandler);
}
function frameHandler(event:Event):void {
if (myArray.length>0) {
textField.appendText(myArray.shift());
} else {
removeEventListener(Event.ENTER_FRAME, frameHandler);
textField.text="";
}
}
p.s. you should mark the actual correct and helpful answers, not just any response of mine. other people use those as shortcuts to find answers quickly, especially the correct answer which is linked in your original post.
North America
Europe, Middle East and Africa
Asia Pacific