  | |  | 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.
|
|
 |