PDA

View Full Version : strict typing and xml problem


servalman
06-12-2004, 04:36 PM
Hello everyone
.
Here is my problem :
1 In an XML file i an attributte called price that as a numeric value (price="10").

2 I Load my MXL file an cycle trought it with a for loop

3 in my for loop i do this :`
// begining of for loop

var my_var:Number = the attribute value

// then if i try this

my_var = my_var + my_var

// i get "1010" as a result of the trace of my_var

// then if i do this

my_var = my_var * my_var

// i get "100" as a result of the trace of my_var

// end of for loop

my question is:

I tought that strict typing was defining the variable as a number in :
var my_var:Number = the attribute value.

I think i did not get something. :confused:

J_Miller
06-12-2004, 06:15 PM
Not sure why it does this, but I have ran into this same problem before. Mine was from remoting results, but Im sure the problem must be one in the same. Anyways, I have gone around this by using the number function to insure the the value is a number. For you it might be something like this:

my_var = Number(my_var) + Number(my_var)

Anyways, hope that helps at all.

servalman
06-13-2004, 04:38 AM
thank you ill try it on mondayand tell you if it works.
Nevertheless i'm trying to understand why it does not work with strict typing as it should.

again thanks a lot

issamneo
06-14-2004, 03:47 AM
yes use the explicit cast Number(my_var) ;)

servalman
06-14-2004, 04:39 AM
It works Thanks a lot to you all

issamneo
06-14-2004, 04:51 AM
see you on the board :)