« A really big thing! | Main | Seeking Myth Busters »

Bug in FlashPlayer 8?

I recently came across an odd issue with FlashPlayer 8. Consider the following ActionScript:

var arr = [];
arr[203] = "�";
arr[235] = "�";
var obj = {};
for (var i in arr) obj[arr[i]] = i;
var t = "";
for (var i in obj) t += i+" - "+obj[i]+" | ";
txt.htmlText = t;

Where 'txt' is a dynamic textfield on the stage.

When this code is published for FlashPlayer6 / ActionScript1.0 (as is the case with the company I work for, I work with MX2004 at the moment) it displays "� - 203 | � - 235 |" in the textfield when viewed with FlashPlayer 6 & 7. It however displays "� - 203 |" when viewed with FlashPlayer 8! It does however show the correct result in FlashPlayer 8 when this code is published for FlashPlayer7 / ActionScript2.0. Very odd and it seems to be a backwards compatibility issue/bug.

Since we use our own custom encoding/decoding scheme to send texts back & forth between Flash and the server which relies on the above-mentioned ability, this is kind of a problem. Is there an easy solution besides publishing for FP7/AS2.0 and thus having to update a lot of applications?

I might actually file this as a bug with Adobe/Macromedia as it isn't, in my eyes, expected behavior/correct backwards compatibility.

Comments

I get " - 203 | - 235 |" in flash 8, windows

M

The funny thing is, that the v8 player behaviour you are seeing is actually correct if you've published to AS1 because AS1 is case-insensitive.

eg:
[code]
obj1 = {};
obj1. = 203;
obj1. = 235;

obj2 = {};
obj2.x = 203;
obj2.X = 235;

output = "";

for(p in obj1)
output += p + ": " + obj1[p] + " , ";

output += newline;

for(p in obj2)
output += p + ": " + obj2[p] + " , ";

txt.text = output;
[/code]

In AS1, v6, the x values are rolled into one but the umlauts aren't. For me, that is inconsistent.

Once you target v7 player, everything is kept separate (as it should be, since that player is case-sensitive for AS1 and AS2).

If you play the AS1, v6 version in the v8 player, it actually behaves consistently - both values are rolled into one for X and for the umlaut.

So it could be that you've just been lucky all this time :) Or perhaps the v6 player didn't support umlauts as valid variable names, whereas the v8 player does.

- Nils.

I just realised you were actually looking for a solution :)

Can you separated lower/upper-case characters into two objects? That way, you would avoid the problems that the case-sensitivity is causing.

You'd presumably have to carry out two lookups instead of one but it's not such a huge increase in overheads since you only have to carry out the 2nd lookup if the first-one failed.

- Nils.

I just tried this with the following results:
Published : 6 AS1
Player Ver: 6
Result txt: - 203 | - 235 |

Published : 6 AS1
Player Ver: 7
Result txt: - 203 | - 235 |

Published : 6 AS1
Player Ver: 8
Result txt: - 203 |

Published : 6 AS1
Player Ver: 8.5
Result txt: - 203 |

Publising to any other version causes the Flash Player 8 result to look like you expected.

It's weird because I would expect the output to be that of Flash Player 8. I would actually see this as a bug from earlier Flash player versions.

As Nils indicated fp6 was case-insensitive, so obj.a and obj.A would have been one, or rather should have been.

Now, you are also correct, because Flash Player 8 shouldn't be changing how older content gets executed. Bugs from fp6 should be present in fp > 6 when playing SWFs published for fp6.