View Full Version : Random text is flash help
Craz
October 25th, 2004, 05:48 PM
How do I do random text in flash without using any php, asp, or any web programming languages?
SmurfMX
October 25th, 2004, 10:23 PM
Well you're going to have to setup an array that contains all the phrases that you want the textbox to be able to show. Something like this.
var phrases:Array = ["What up doc?", "Bazing!", "OMFG SPANDEX", "Mmmmm naked"];
Next you'll have to write a function that'll change the textbox's text.
function changePhrase(Void):Void{
//get a random quote and use length-1 as arrays begin at 0
_root.myTxtBox.text = phrases[random(phrases.length-1)];
}
Now to have our quote change every 2 seconds we can easily use set Interval (http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary646.html). But first we have to call it so our textbox actually has text and isnt blank for 2 seconds.
changePhrase();
setInterval(changePhrase, 2000); //2000 cause setInterval is in MS
Hope that helped :).
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.