Adobe Dreamweaver Forums



Last 10 THreads :         Strip EXIF camera data from PSD files? (Last Post : Russell_Proulx@adobeforums.com - Replies : 2 - Views : 3 )           »          CSH Calls for Merged CHM's (Last Post : TrentSnake - Replies : 0 - Views : 1 )           »          Image Replacement (Last Post : WhatNow - Replies : 0 - Views : 1 )           »          Embedding Flash SWF Skin in External Site (Last Post : QADesign - Replies : 0 - Views : 1 )           »          Compatible issue with ie6 (Last Post : zhtjlong - Replies : 0 - Views : 1 )           »          Re: Photoshop CS4 is a disaster (Last Post : Paulo_Skylar@adobeforums.com - Replies : 0 - Views : 1 )           »          Query question/help (Last Post : trojnfn - Replies : 2 - Views : 3 )           »          CS4 Motion Editor issues (Last Post : aaronlyon - Replies : 4 - Views : 9 )           »          Bridge No Longer Rotates Automatically (Last Post : Michael_Palumbo@adobeforums.com - Replies : 1 - Views : 2 )           »          dollarFormat / numberformat problem (Last Post : izdabye - Replies : 0 - Views : 1 )           »         


User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Labs > Flashplayer 10
 
Tags:



Reply
  #1 (permalink)  
Old 10-01-2008, 04:26 PM
mrgooberbot
 
Posts: n/a
Diggs:
Default type casting

Previous versions use to automatically evaluate strings as numbers. In the new
version, strings are not automatically evaluated as integers.

For example, previous versions set "result" as TRUE:

var myNumber = "7";
if(myNumber > "5"){
result = TRUE;
} else {
result = FALSE;
}

The new player sets "result" as FALSE.

Older flash plugins would automatically evaluate the strings "7" and "5" as
numbers. However the new flash player does not.

So... it seems like the new flash player version 10 is more strict with regard
to type casting?

The example is based on an SWF that is output as Flash version 8, actionscript
version 2.





Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-17-2008, 08:38 AM
Reality Developer
 
Posts: n/a
Diggs:
Default 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.

Reply With Quote
  #3 (permalink)  
Old 11-21-2008, 04:26 AM
xXx--mr-G--xXx
 
Posts: n/a
Diggs:
Default Re: type casting

The issue is not the evaluation of the word "five" or "seven" -- but rather the
evaluation of the number "5" or "7" when the number is wrapped in quotes. When
a number is wrapped in quotes, it is now being interpreted as a "string" and
not an integer number.

Older versions of the plugin would automatically convert the integers that
were wrapped with "quotes" into true integers. The new version of the plugin no
longer auotmatically converts integers that are wrapped in quotes (e.g.
strings) as if they were integer numbers.

Reply With Quote


  #4 (permalink)  
Old 11-22-2008, 01:17 AM
Reality Developer
 
Posts: n/a
Diggs:
Default Re: type casting

The example with "five" and "seven" was to show you that the '<' and '>'
operators when used with strings, work by comparing the string characters using
alphabetical order. Previous version of flash worked the same. "5" and "7" were
not converted to integers, but were rather compared as strings. Since "5" is
before "7" in alphabetical order, you would get the result that 5 is less than
7. The new player works the same, and I ran your example code and it works just
fine. You must have a different issue in your code that is causing your issue.
Look in the flash help file under operators to see how it works. It clearly
states that numbers as strings get interpreted as strings... by checking each
char in the alphabetical order and hence "5" is less then "7". The are not
converted to true integers and never were.

Reply With Quote
  #5 (permalink)  
Old Yesterday, 05:47 PM
xXx--mr-G--xXx
 
Posts: n/a
Diggs:
Default Re: type casting

The issue is not the evaluation of the word "five" or "seven" -- but rather the
evaluation of the number "5" or "7" when the number is wrapped in quotes. When
a number is wrapped in quotes, it is now being interpreted as a "string" and
not an integer number.

Older versions of the plugin would automatically convert the integers that
were wrapped with "quotes" into true integers. The new version of the plugin no
longer auotmatically converts integers that are wrapped in quotes (e.g.
strings) as if they were integer numbers.

Reply With Quote
  #6 (permalink)  
Old Yesterday, 05:47 PM
Reality Developer
 
Posts: n/a
Diggs:
Default Re: type casting

The example with "five" and "seven" was to show you that the '<' and '>'
operators when used with strings, work by comparing the string characters using
alphabetical order. Previous version of flash worked the same. "5" and "7" were
not converted to integers, but were rather compared as strings. Since "5" is
before "7" in alphabetical order, you would get the result that 5 is less than
7. The new player works the same, and I ran your example code and it works just
fine. You must have a different issue in your code that is causing your issue.
Look in the flash help file under operators to see how it works. It clearly
states that numbers as strings get interpreted as strings... by checking each
char in the alphabetical order and hence "5" is less then "7". The are not
converted to true integers and never were.

Reply With Quote


  #7 (permalink)  
Old Yesterday, 07:54 PM
xXx--mr-G--xXx
 
Posts: n/a
Diggs:
Default Re: type casting

The issue is not the evaluation of the word "five" or "seven" -- but rather the
evaluation of the number "5" or "7" when the number is wrapped in quotes. When
a number is wrapped in quotes, it is now being interpreted as a "string" and
not an integer number.

Older versions of the plugin would automatically convert the integers that
were wrapped with "quotes" into true integers. The new version of the plugin no
longer auotmatically converts integers that are wrapped in quotes (e.g.
strings) as if they were integer numbers.

Reply With Quote
  #8 (permalink)  
Old Yesterday, 07:54 PM
Reality Developer
 
Posts: n/a
Diggs:
Default Re: type casting

The example with "five" and "seven" was to show you that the '<' and '>'
operators when used with strings, work by comparing the string characters using
alphabetical order. Previous version of flash worked the same. "5" and "7" were
not converted to integers, but were rather compared as strings. Since "5" is
before "7" in alphabetical order, you would get the result that 5 is less than
7. The new player works the same, and I ran your example code and it works just
fine. You must have a different issue in your code that is causing your issue.
Look in the flash help file under operators to see how it works. It clearly
states that numbers as strings get interpreted as strings... by checking each
char in the alphabetical order and hence "5" is less then "7". The are not
converted to true integers and never were.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 04:02 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk