associative arrays

  • Buck Nasty
  • Novice
  • Novice
  • User avatar
  • Posts: 21
  • Loc: Philadelphia

Post 3+ Months Ago

Does anyone know a good tutorial anywhere on associative arrays? I am trying to create an array that I am adding elements to when a certain key frame is reached and deleting the element when another key frame is reached. Associative arrays seem to be the best for this since the movie clips can be randomly hit so the order of the array when populated can be in any order. So I want to be able to pull it out by name instead of the numbered order.
I was looking in the actionScript cookbook and in the definitive guide and they have examples but even when i just test it with a trace in a new document it doesnt seem to work.

Here is a small example of what i was doing just to test to see if it would
populate the array with one element:

_root.myArray = new Array();
_root.myArray["r2"] = "r2";
trace(_root.myArray());
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

What would be called an Associative Array in some languages, is refered to as an Object in Actionscript.

Code: [ Select ]
_root.myObject = new Object();
_root.myObject["r2"] = "r2";
trace(_root.myObject.r2);
  1. _root.myObject = new Object();
  2. _root.myObject["r2"] = "r2";
  3. trace(_root.myObject.r2);
  • Buck Nasty
  • Novice
  • Novice
  • User avatar
  • Posts: 21
  • Loc: Philadelphia

Post 3+ Months Ago

Thanks.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 11 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.