Re: [flexcoders] Information on how to Create Objects on the fly with Code

2007-05-31 Thread Michael Schmalle

Hi,

var len:int = buttons.length;
for (var i:int = 0; i  len; i++)
{
  var obj:OBject = buttons[i];
  var button:Button = new Button();
  button.label = obj.label;
  container.addChild(button);
}

I think you get the hint. This is VERY basic compared to what you can do
dynamically.

Depending on what is in the array, you could do fancy switches or even use
getClassByDefinition() and create any loaded class component you want.

Peace, Mike


On 5/31/07, Dave @ VitalPodcasts.com [EMAIL PROTECTED] wrote:


  Is there are resources out there on how to create, let's say a button,
on the fly with Code?

Im trying to create an Array, and I want to loop around it to create a
list of Buttons for navigation.

 





--
Teoti Graphix
http://www.teotigraphix.com

Blog - Flex2Components
http://www.flex2components.com

You can find more by solving the problem then by 'asking the question'.


RE: [flexcoders] Information on how to Create Objects on the fly with Code

2007-05-31 Thread Tracy Spratt
And here is a full example app:

http://www.cflex.net/showFileDetails.cfm?ObjectID=562

 

At the simplest level, it is very simple!

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Michael Schmalle
Sent: Thursday, May 31, 2007 12:03 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Information on how to Create Objects on the
fly with Code

 

Hi,

var len:int = buttons.length;
for (var i:int = 0; i  len; i++)
{
   var obj:OBject = buttons[i];
   var button:Button = new Button();
   button.label = obj.label;
   container.addChild(button); 
}

I think you get the hint. This is VERY basic compared to what you can do
dynamically.

Depending on what is in the array, you could do fancy switches or even
use getClassByDefinition() and create any loaded class component you
want. 

Peace, Mike



On 5/31/07, Dave @ VitalPodcasts.com [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:

Is there are resources out there on how to create, let's say a button, 
on the fly with Code?

Im trying to create an Array, and I want to loop around it to create a 
list of Buttons for navigation. 




-- 
Teoti Graphix
http://www.teotigraphix.com http://www.teotigraphix.com 

Blog - Flex2Components
http://www.flex2components.com http://www.flex2components.com 

You can find more by solving the problem then by 'asking the question'. 

 



Re: [flexcoders] Information on how to Create Objects on the fly with Code

2007-05-31 Thread David McGraw

Solved this,
For anyone that may need this, you have to use addChild() as Below.

var myNewButton:Button = new Button();
parent.addChild(temp);




On 5/31/07, Dave @ VitalPodcasts.com [EMAIL PROTECTED] wrote:


  Is there are resources out there on how to create, let's say a button,
on the fly with Code?

Im trying to create an Array, and I want to loop around it to create a
list of Buttons for navigation.