Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 8. Arrays > Amazing Properties of Arrays

8.10. Amazing Properties of Arrays

Before we say farewell to Array, let's recap a few of its fantastic properties and make some quick observations on how ActionScript 3.0 arrays compare to similar data types in other languages. Arrays are possibly the most versatile tool in ActionScript.

  • Arrays are dynamically sized. You never have to do anything to allocate more memory for them or free memory they're not using.

  • Arrays are always mutable. You can always create, remove, update, and delete values from them.

  • Arrays support list operations like push() and pop(), and functional programming like filter() and map().

  • Arrays are mixed. You can put multiple types into an array, even if they're not the same type.

  • Arrays can be sparse, meaning that you can have a gap in the indices of an array. This can be really helpful or really dangerous. Use with caution.

    var arr:Array = ["zero", "one", "two"];
    arr[5] = "five";
    trace(arr); //zero,one,two,,,five

  • Arrays can be associative, but you should probably leave that up to Objects, as mentioned earlier.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial