PDA

View Full Version : Does Flash know a function like TypeCast?



moonless_planet
May 10th, 2005, 03:33 AM
I need to add values in a string (they're strings because I get a date as timestamp from a database and then pluck it apart in Flash with substring). Flash doesn't do math with strings. (doh!) So is there a way to cast the string into an integer value?

glkngs
May 10th, 2005, 03:57 AM
a simple Numer("4") will do the trick in most cases :)

moonless_planet
May 10th, 2005, 04:28 AM
hm, simple, eh.

However, a thing like this: _root.creation_month=Number(_root.creation_month.s ubstring(1))
does not seem to work so well. I'm not sure actually. Because in part it seems to be working and in part not. Haven't quite figured it out.
Any further tips?

senocular
May 10th, 2005, 05:43 AM
ar you sure your substringed string is a number? Might want to check that out as well.

You also have parseInt and parseFloat which might be helpful as well (and offer other behavior over Number())

moonless_planet
May 10th, 2005, 06:36 AM
yep, I made sure it's a number before I started anything else. Well, parseInt does the trick. Thanks a lot!