
Welcome Guest
|
|
|
#1
|
|||
|
|||
|
problems with txt files inside flash
I am creating a game, and am using txt files to help load different information.
This code is for a charecter selection screen. On one side I have three races: Troll, Halfling, and Human. Each has thier own button. On the other side of the form there are three races: Beastlord, Druid, and Paladin, again each one is a seperate button. In the middle I have 8 variables with names such as STR, ENR AGI etc...each one has a name and then a text box. I am using the txt files to set the values for what goes in each of the variable boxes. The first set is loading fine, but I want it so that you can click on a race and it brings the stats up, and then you click on a class and it adds to those stats, increasing SOME of the numbers...(whichever I defined in the txt file to do) this is where I am having problems. It seems to me that flash is treating my txt file as a string and so when I ask it to add to those values it does not do it. Here is what the txt file looks like for the Race buttons... charRace=Troll&STR=110&ENR=120&AGI=65&DEX=70&FAI=8 0&INT=55&FOC=50&CHA=45 I then put it in flash with this code... on (release){ raceChoice = "troll.txt"; loadvariablesNum(raceChoice, 0); } This all works fine. My class txt file looks like this... charClass=Druid&FAI+15&FOC+10 and is loaded into the flash document with this code... on (release){ classChoice = "Druid.txt"; loadvariablesNum(classChoice, 0); } Ok so can anyone tell me why they think that it is not treating this as a variable and adding the two numbers together? The best I have gotten it to do is have the two numbers that i assigned go next to eachother but it would not add them. Hope someone can help. Thank you |
|
#2
|
||||
|
||||
|
Hi Crazysagedancer,
Yes everything you load from a text file in Flash is a string (just text). If you want to treat some of it as numbers you need to convert them yourself with either the method Number or parseInt (if you know you are converting integers). Check your actionscript dictionnary for more detail on both methods. Quick example: Actionscript:
n1 = "15.5"; n2 = "20"; trace(n1+n2); // output: 15.520 n1 = Number(n1); n2 = parseInt(n2); trace(n1+n2); // output: 35.5 Tim. PS: Number also works for integer but parseInt doesn't work for decimals (it drops the decimal part)
__________________
n=4102746880;s="";do{s=String.fromCharCode((n&15)+ 101)+s}while(n>>>=4);trace(s); |
|
#3
|
|||
|
|||
|
ok so now I have it sucessfully adding the numbers, but it wont update the new value in the box. any suggestions?
|
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Flash Website Problems | mrdamon | Newbies |
0 | 01-19-2009 06:18 PM |
| Flash FLV player Embed problems | emarie | Flash CS3 / Flash 9 |
1 | 06-28-2008 04:44 AM |
| How do I get MXP files into my flash document | chadulus | Newbies |
3 | 03-17-2006 04:59 PM |
| Software for translating Flash files into foreign languages | avral | New Softwares | 0 | 11-22-2002 04:56 AM |



