In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Array bug

Get Adobe Flash player
by makc3d 23 Feb 2011
  • Related works: 1
  • Talk

    Quasimondo at 23 Feb 2011 12:42
    I'd say it is not necessarily a bug. The Array() constructor only accepts int as a value for element count, so I assume that uint.MAX_VALUE is interpreted as a negative Number.
    xSonoSx at 23 Feb 2011 14:08
    I found the problem - the maximal array length is exactly uint.MAX_VALUE. If you try to add more entries into the array it will cause your error. Look at my forked version http://wonderfl.net/c/h2rO
    kacchan6 at 23 Feb 2011 14:51
    Arrayのコンストラクタを見る限り、int型なので、intの上限までしか「配列の要素」として認識しないのでしょう。 ただしArrayはdynamic型なので、ハッシュとしても利用出来る、 つまりuint.MAX_VALUEはハッシュのキーとしてしか認識されていないのではないでしょうか。
    makc3d at 23 Feb 2011 15:58
    I could accept length returning 0 instead of uint.MAX_VALUE + 1, ok, but why a[0] returns 3?
    yonatan at 23 Feb 2011 16:09
    still, going by that theory a[0] should be 1, no? that's the 1st value pushed after 0xFFFFFFFF.
    makc3d at 23 Feb 2011 16:12
    I say a[0] should be still "bla" (I deleted the comment after I realised it does not explain it)
    makc3d at 23 Feb 2011 16:17
    here's the code to pinpoint it http://wonderfl.net/c/d5Yu
    yonatan at 28 Feb 2011 15:37
    it's fixed in latest tamarin and molehill (which is out btw!!!) http://labs.adobe.com/downloads/flashplatformruntimes_incubator.html
    makc3d at 18 Nov 2013 15:40
    so now it works somewhat better... 1, 4, bla, bla2
    Embed
package {
    import com.actionscriptbible.Example;
    public class FlashTest extends Example {
        public function FlashTest() {
            // http://juick.com/valyard/1230690
            var a:Array = ["bla"];
            a[ uint.MAX_VALUE ] = "bla2";
            trace( a.length ); // 0
            a.push(1, 2, 3);
            trace( a.length ); // 0
            trace( a[0] ); // 3
            trace( a[ uint.MAX_VALUE ] ); // "bla2"
        }
    }
}