RE: [flexcoders] Removing children when they have no id

2007-09-18 Thread Alex Harui
I'd keep an array of labels.

 

But you can search as well by testing if getChildAt(i) is Label

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of donvoltz
Sent: Tuesday, September 18, 2007 10:21 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Removing children when they have no id

 

Hi everyone,

I am using the following code to dynamically add a number of labels to 
a panal.

for each (var item:XML in dataStream){
var someLabel:Label = new Label();
someLabel.text = item..title;
addChild(someLabel);
}

This works well, however, I am now up against a problem. Each of these 
labels does not have an id so I have no way to access them individually.

What I need to do is remove all of the labels when a user clicks a 
button, however, I can not use removeChild() since I do not have an id 
to each label, and infact, may not even know programatically how many 
labels are in the panal since it depends on what was returned from a 
database.

Any help on how I can "reset" this panal by removing the labels when a 
button click event occurs would be appreciated

Thanks 

Don

 



RE: [flexcoders] Removing children when they have no id

2007-09-18 Thread Gordon Smith
Make someLabel an instance var of your component or application rather
than a local var inside a method. An MXML tag declared with an id causes
simply such an instance var to be autogenerated by the MXML compiler.
 
- Gordon



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of donvoltz
Sent: Tuesday, September 18, 2007 10:21 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Removing children when they have no id



Hi everyone,

I am using the following code to dynamically add a number of labels to 
a panal.

for each (var item:XML in dataStream){
var someLabel:Label = new Label();
someLabel.text = item..title;
addChild(someLabel);
}

This works well, however, I am now up against a problem. Each of these 
labels does not have an id so I have no way to access them individually.

What I need to do is remove all of the labels when a user clicks a 
button, however, I can not use removeChild() since I do not have an id 
to each label, and infact, may not even know programatically how many 
labels are in the panal since it depends on what was returned from a 
database.

Any help on how I can "reset" this panal by removing the labels when a 
button click event occurs would be appreciated

Thanks 

Don