I found a minor bug (sort of..) in the public release of Flash Player 7..  release 7,0,14,0
(( I found out on 10/2/03 that this bug was fixed.. and that the fix would be in the next release of the player which will be out “later this year"))

I found a minor bug (sort of..) in the public release of Flash Player 7..  release 7,0,14,0

((this bug was fixed in Flash Player 7.0.19.0 12/16/03 but I’m leaving this info here because there will still be people using 7,0,14,0 for some time..))

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="254" HEIGHT="148" ALIGN="top">
TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">

The example above shows sorting by length of the string in the array.. it works in both Flash Player 6 and 7.

However.. if I change

if (a.length >= b.length){
to
if (a.length > b.length){

It will crash Flash Player 7 dramatically.. giving the script timeout error, and sometimes closing the browser without any warning. Yet the same code will compile just fine in Flash MX and will display without incident in Flash Player 6.  I know it’s bad coding..  it showed up on my radar because it was in an old project I did where I ported some ASP code over to ActionScript and didn’t double check the logic used in the original code.

What’s happening is one or more array elements fail the sort method because the order(a,b) function does not return the expected “1” or “-1”. Apparently Flash Player 6 is not strict about this.. and Flash Player 7 is???

To see an the example of the "invalid" code that will display in Flash Player
6 but will crash Flash Player 7 --> click here.





suggestionArray = new Array("apple","bug","frog","dog","pineapple");

mytext = main();

function main(){
    wordArray.sort(order);
     wordString = wordArray[0];
     for (var q = 1; q<5; q++) {
          wordString += "r"+wordArray[q];
     }
     return wordString;
}


function order(a, b) {
     if (a.length >= b.length){
          return -1;
     } else {
          return 1;
     }
}