FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


CALLING ALL ACTIONSCRIPTERS, NEED HELP ASAP (IM SERIOUS)





DJGuardy
Ok everyone heres the deal. Thanks for reading the post by the way. Anyway, I have a .txt file with the variable content of name01= &name02= etc. etc. Now, I am generating a random name number (such as name04) in flash using the Math.floor and Math.Random ()*6 actionscript, with success. Now, what I am trying to do is use the dynamic text with the randomly generated name and number text, in conjunction with the text file. For example, if the generator appears with name02, another dynamic text box will show the value of name02 in the text file. Yet I have tried everything and cannot get anywhere. SOMEONE PLEASE HELP, THIS IS NEEDED FOR FRIDAY!

Source files are going up.

http://djguardy.frihost.net/flashhelp/help.fla
http://djguardy.frihost.net/flashhelp/name.txt
http://djguardy.frihost.net/flashhelp/test.swf

PLEASE FOR FRIDAY, HELP ME!

If you guys get this for me, you rock the worlds socks Smile
Kaneda
First of all, you need to give instance names to your dynamic text fields or you can't assign any text to them from ActionScript. In this case, I've used txtName and txtNumber for the two fields.

I've assumed you're using FlashMX 2004 or Flash 8. Otherwise you'll need to change the following to ActionScript 1.0 syntax. I'm also assuming at least FlashPlayer 6, where the LoadVars object was introduced. This makes timing easier, since loadVariables is asynchronous, and thus, when you start assigning the values from the text file, you can't really be sure the text file has actually loaded. LoadVars' onLoad event takes care of that.

Anyway, then the script goes:

Code:
var names:LoadVars = new LoadVars();
names.onLoad = function() {
  var i:Number = Math.ceil(Math.random()*5); // Pick a number between 1 and 5
  var varname:String = "name" + i;
  txtName.text = this[varname];
  txtNumber.text = i;
}
names.load("name.txt");


Here, the code is written for numbers between 1 and 5, since that's the variables you have in name.txt. Smile
Related topics
Free games
Any One good at webdesign
i did a 755 on all files and it doesent help
All About WoW
Jail Time
Ajax or JS - need help ASAP
Help
PLEASE HELP!!.......PLEASE
help|
batman font
pls help me.. what will i do.. will i get pregnant??
Dont Get anything about hosting
Collecting Coins ?
Help coding a php back end for an xml website! Radio646.com
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.