A Flash Developer Resource Site

Results 1 to 20 of 22

Thread: Logic Bomb... Retrieving "negative" index, and wrap around an Array?

Threaded View

  1. #10
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    That would cause more problems. If you use arrays to keep track of objects, especially when using multi-dimensional arrays, you would no longer have the ability to see if an object has been set for a particular cell. Example...

    say that I want to get a bitmap from my array that has an index of 16. I would normally retrieve with something like this...

    Code:
    function getBitmap(n:uint):BitmapData
    {
       return myArray[n] ||= bitmapLoader(n);
    }
    
    var bmp:BitmapData = getBitmap(16);
    so the function above would either return the BitmapData that's stored in myArray[n] or load and return a new bitmap. With the index-wrapping feature, that would no longer be the case.

    --- edit ---

    though, that's not to say that the function itself wouldn't be useful. Just, as a static function either in Math or Array, and not implemented as a default.
    Last edited by Ralgoth; 01-17-2010 at 10:59 PM.
    Search first, asked questions later.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center