I have the following code
function _getTime(msgStr){
var theStr:int = (int)msgStr.split(' ');
return theStr;
}
And am recieving the following error.
Expecting Semicolon Before msgStr
Not sure what the problem is
I am trying to convert this PHP function. Found online to use split but it does not seem to work.
function _getTime($msgStr){
return (int) strtok($msgStr,' ');
}
1) Type casting in ActionScript works like this:
instead of
2) AsTheWormTurns is right:
split()returns an array of strings – you cannot cast it toint. If I understand the PHP function correctly, it returns only the first entry of that array asint. So what you are looking for should be:or even simpler, since parseInt() parses everything until the first non-numerical character: