- Home /
Question by
TheCoolDog · Jan 19, 2013 at 07:21 PM ·
errorstringintconvert
js "Cannot convert 'String' to 'int'." error
Help i'm getting this error:
Ball.js(9,19): BCE0022: Cannot convert 'String' to 'int'.
Here is that part of the script:
var max_speed:int;
private var n_max_speed:int;
private var s_max_speed:int;
s_max_speed = "-" +max_speed.ToString(); // line 9
n_max_speed = parseInt(s_max_speed);
Comment
Best Answer
Answer by j0ffe · Jan 19, 2013 at 07:30 PM
The problem is that you convert max_speed to a string and then try to put in a int variable. I guess you want to put s_max speed to the negative of the max_speed? If so you can do like this instead:
s_max_speed =- max_speed
Thanks! And I just figured out my problem by looking at your answer. s_max_speed is meant to mean string_max_speed but I assigned it as an int! But i'm going to use your method because it's much shorter and efficient. Thanks again.
oh and yes I was trying to set it to negative max speed.