There is no literal syntax that is shorthand for creating class instances.
Think ahead and consider whether your data will be declared in code or will
come from a server. Usually it comes from a server and some other logic
will create the class instances.
If you want to create a bunch of classes instances in code, I often add a
public class BakedGood
public function BakedGood(name:String = null,
color:uint = 0;
hasFilling:Boolean = false)
this.name = name;
this.color = color;
this.hasFilling = hasFilling;
public var name:String;
public var color:uint;
public var hasFilling:Boolean;
Then create them like this:
new BakedGood("muffin", 0x123456, false ),
new BakedGood("pie", 0x654321, true ),
new BakedGood("cake", 0x121212, false )
Not coming from a server in this case; just embedded in code.
Thanks for the great alternative.
1 person found this helpful
You can also use MXML:
<fx:Vector id="wares" type="BakedGood">
<BakedGood name="muffin" color="0x123456" hasFilling="false"/>
<BakedGood name="pie" color="0x654321" hasFilling="true"/>
<BakedGood name="cake" color="0x121212" hasFilling="false"/>
Adobe Flex SDK Team
I didn't know about that option either. Thanks!