-
Variables: adding a variable to another set of variables
Hi, im trying to add a set of variables to create a total how i've done it is:
_root.total = _root.variable1+_root.variable2+_root.variable3;
etc...
however... it does not work!!!!!!
instead of adding the variables up and gettin the sum instead it just adds the number from variable1 variable2 and variable3 to _root.total
EG.
total = 0
variable1 = 2
variable2 = 3
variable3 = 4
then it makes it like this..
total = 0234
i've tried doing it many different ways but it just wont work the way i want it to. plz help, its probably something stupid that i've forgotten, all helps appreciated. thanks.
I'm using Flash 8 on a Mac
-
Make sure that variable1-3 are number types. In their definition use:
var variable1:Number = 2;
var variable2:Number = 3;
var variable3:Number = 4;
-
Or just cast them as numbers:
total = Number (var1) + Number (var2)...
The greatest pleasure in life is doing what people say you cannot do.
- Walter Bagehot
The height of cleverness is to be able to conceal it.
- Francois de La Rochefoucauld
-
I tried blazes way, which didnt seem to work
I'll try your method out 691175002.
I'll get back to you and let you know if it worked thanks
I'm using Flash 8 on a Mac
-
Sorry for the double post... but, apparently i cant edit my posts after 10 minutes has passed. Anyway, your method worked perfectly thanks for the help. BUT is there anyway that i could make it so the total = Number(var1)+Number(var2);
AND
The variables as input text fields and whenever the variables in the input text field are changed the total is automatically updated?
I'm using Flash 8 on a Mac
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|