Mailing List
Home
Forum Home
Flash Pro
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
RES: [Flashcoders] multidimensional array questions - from a director programmer

RES: [Flashcoders] multidimensional array questions - from a director programmer

2004-02-26       - By JayFlash

 Back

Array.prototype.getByName = function(obj){
  for(i=0;i<this.length;i++){
    if( this[i]==obj){
      return this[i];
    }
  }
}


myArray = [];
myArray = new Array();
myObject = new Object();
myObject.name = "fred";
myObject.age = "19";
myArray = [true, "ball", myObject];


trace(myArray.getByName(myObject)["age"]); // traces 19



But maybe you want to avoid loops at all?

Anyway, I supose that you could also completely drop the idea of using
arrays and simply use functions to store objects inside objects.
That way you're garanteed to be able to access them by the handlers.


Just my impressions on this.

Thanks,

Jay





-- --Mensagem original-- --
De: rise4peace@(protected) [mailto:rise4peace@(protected)]
Enviada em: quarta-feira, 25 de fevereiro de 2004 17:14
Para: flashcoders@(protected)
Assunto: Re: [Flashcoders] multidimensional array questions - from a
director programmer (long)


Jason,

I think I am beginning to understand. I am still a little unsure how I can
access the object data that is stored in the array though:

Simple example:

myArray = [];
myArray = new Array();
myObject = new Object();
myObject.name = "fred";
myObject.age = "19";
myArray = [true, "ball", myObject];
trace(myArray[1]);

This traces out to :

ball

If I then want to grab the age property from the myObject pointer stored in
the myArray I use this:
trace(myArray[myObject]["age"]);

This traces out to:

undefined

Why?

thanks for the help,

rise4peace


=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:105240
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)




=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:105313
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)




Earn $52 per hosting referral at Lunarpages.