First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Eddie Carroll | Website: http://www.flashkit.com

Reference Data Types

The reference data type is more advanced. The difference between them and primative data types is very simple - as I mentioned before the primitive data types physically hold the value (the container analogy), the reference data type instead holds information that "points" to where the actual value resides (where the container is). Objects and movie clips are the two types of reference data types.

The benefit of using a reference is you only have to change a value once. All references to that particular value will then be reflected throught your movie. An example of an Object data type is an Array is essentially an indexed group of variables.

Let's have a look at an example of some actionscript to highlight the way reference data types work. In the example we'll be using an Array Object. But for now, don't worry about the details of an array just think of it as a table with rows of cells (a cell in an array is called an element), in this case we're using a single row of elements. Arrays will be discussed in more detail later.

Notice how after we made a copy of "myArray" and called it "copyOfArray", we changed the value of copyOfArray[3] by changing the corresponding element in "myArray". We didn't have to touch "copyOfArray". This is essentally a reference in action. The array "copyOfArray" only holds information that points to a physical place in your computers memory where the value is stored (consider it an address). Confused?

Let's expand on the address analogy. If I gave you my website address, I wouldn't be giving you all my website files. I would simply be giving you some information that points to a physical location on a server where my website files reside. This is very different to the way primitive data types work, which physically contain the values. To carry on the analogy, a primative would be like me handing over a disk with all my website files instead of giving you an address.

» Level Basic

Added: 2000-10-26
Rating: 8 Votes: 91
(10 being the highest)
» Author
Eddie was a Content Editor at Flashkit.com and is actually a sentient Gateway Solo 2150xl notebook that suffers from acute lysdexia and caffeine addiction. He is carried on the shoulders of a semi-autonomous human called "Body".
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.