If you know the array elements at compile time, the [ ] array-literal syntax is more readable and produces smaller and faster code:

 

    public var myArary:Array = [ new xClass(), new yClass(), new zClass() ];

 

You don't need to set each element one at a time.

 

- Gordon

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jose (DSM) Lora
Sent: Wednesday, January 04, 2006 6:31 AM
To: [email protected]
Subject: RE: [flexcoders] Need Help with Complex Array Syntax

 

Try

public var myArray:Array = new Array();
myArray[0] = new xClass();

myArray[1] = new yClass();

myArray[2] = new zClass();

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Libby
Sent: Wednesday, January 04, 2006 8:28 AM
To: [email protected]
Subject: [flexcoders] Need Help with Complex Array Syntax

 


I am trying to create an array of Objects and each is a different
class.  Is it possible to create the array while telling the class
type of each object? On a plain old single Object instantiation you
might do this:
public var x:xClass;
x = new xClass();

I am trying to create an array of these objects (below), but Flex
doesn't like my ":" syntax in the array definition. What am I doing wrong?

public var myArray:Array = new Array(x:xClass,y:yClass,z:zClass);
myArray[0] = new xClass();

Thanks for your help,
Libby







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to