Re: type casting
What player (exact version) are you using, as in target build and the player
you ran it in?
I just did a few of tests using your code, building the swf in CS3 and the
last in Flex 3 Compiler:
Target player Flash 8 with AS2 running in Flash Player 9.0.124.0,
Target player Flash 8 with AS2 running in Flash Player 10.0.12.10 Beta,
Target player Flash 9 with AS3 running in Flash Player 9.0.124.0,
Target player Flash 9 with AS3 running in Flash Player 10.0.12.10 Beta,
Flex 3 Compiler target Flash 10 Beta running in Flash Player 10.0.12.10 Beta
(my current environment),
All of which did return the correct result. As in true. (TRUE however gives
undefined in some cases, so I just changed your caps TRUE/FALSE to lower case
true/false, but thats not the issue you're having).
I don't have FP 10.0.12.36 yet as I'm just shocked that final is released
already. And just look at the versions, last beta was 10.0.12.10 and the final
is 10.0.12.36... so if versioning is [ major . minor . revision . 4th number ]
(I'm not really sure what the 4th number means... some kind of build maybe,
which is the part that shocks me... only 26 'builds' later and the beta became
a final? Not even a revision version change? Ouch!)
Also, Flash Players (including FP 10.0.12.10 Beta, and the final FP 10.0.12.36
probably) don't evaluate strings as numbers. Strings are actually evaluated as
text using the alphabetical order. Here's a line from the Flash CS3 IDE Help
File: "String expressions are evaluated using alphabetical order; all capital
letters come before lowercase letters." So in your example, I was getting
'true' because the character '7' comes after the character '5', not because the
strings were converted to numbers. Here's some code that demonstrates why thats
important to keep in mind...
The following code returns true:
var myNumber:String = "seven";
var result:Boolean;
if( myNumber > "five" ){
result = true;
} else {
result = false;
}
trace(result);
// trace will print: true
However, the following code will return false:
var myNumber:String = "SEVEN";
var result:Boolean;
if( myNumber > "five" ){
result = true;
} else {
result = false;
}
trace(result);
// trace will print: false
As you can see (I'm assuming your environment does the same), you might assume
that 'SEVEN' will be evaluated as greater than 'five', but its not, because
capital letters come before lower case letters. So it's important to test
strings in the same case (both capital or lower) unless you have reason to use
the strings as the are and know what to expect from the results.
I'm not sure what exact player you're using, but I couldn't reproduce your
results in any of my test cases.
|