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

2007-09-19 Thread donvoltz
Thanks so much for your help Alex! The support on this forum is 
excellent

Don



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

2007-09-18 Thread Sandeep Malik
Cant you use removeAllChildren()?

Regards,
Sandeep

--- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote:

 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





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

2007-09-18 Thread donvoltz
Thanks to all for the help but I am still seeing some issues I do not
understand

I have done the following

private var labelCollection:ArrayCollection = new ArrayCollection();
//place to hold the label instances

private function makeLabelHandler(event:ResultEvent):void {

...process data and construct new labels

labelCollection.addItem(newLabel);
this.addChild(newLabel);
}
}

On a button click I call the following function

private function resetCallLocations():void {

for each (var someLabel:Label in labelCollection){

removeChild(ff);
}

This returns the following error

ArgumentError: Error #2025: The supplied DisplayObject must be a child
of the caller.

Am I setting this up correctly or is this not the way to instantiate
many labels

Thanks for the help

Don





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

2007-09-18 Thread Alex Harui
Is it possible that you are not removing from the container you added
to?  Is this on the first reset or subsequent?  If not the first, then
the prob might be that you aren't resetting the labelCollection.

 

FWIW, it is probably  overkill to use AC instead of an array here.

 



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

 

Thanks to all for the help but I am still seeing some issues I do not
understand

I have done the following

private var labelCollection:ArrayCollection = new ArrayCollection();
//place to hold the label instances

private function makeLabelHandler(event:ResultEvent):void {

...process data and construct new labels

labelCollection.addItem(newLabel);
this.addChild(newLabel);
}
}

On a button click I call the following function

private function resetCallLocations():void {

for each (var someLabel:Label in labelCollection){

removeChild(ff);
}

This returns the following error

ArgumentError: Error #2025: The supplied DisplayObject must be a child
of the caller.

Am I setting this up correctly or is this not the way to instantiate
many labels

Thanks for the help

Don

 



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

2007-09-18 Thread donvoltz
Hi Alex,

You were correct in your question, this does not happen after the
first click, but after the second one.

See what I am doing is first establish the labels as listed above,
Then call a function on the click event to remove the labels, and
rebuild them with a different data set. (I would think this should
work like it did on the first go round).

Does this shed any additional light on why I am receiving this error

Thanks

Don



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

2007-09-18 Thread Alex Harui
As I mentioned, you are not resetting labelCollection, or calling
removeItemAt from labelCollection as you call removeChild().

 



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

 

Hi Alex,

You were correct in your question, this does not happen after the
first click, but after the second one.

See what I am doing is first establish the labels as listed above,
Then call a function on the click event to remove the labels, and
rebuild them with a different data set. (I would think this should
work like it did on the first go round).

Does this shed any additional light on why I am receiving this error

Thanks

Don