I think that if statement should be
if (counter > 0)
{
this.destroyChild(rowArray[counter-1]);
counter--;
}
Matt
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of rgwilson26
Sent: Tuesday, February 21, 2006 8:56 AM
To: [email protected]
Subject: [flexcoders] createChild and destroyChild
I am new to FLEX and am working on an app that allows the user to
dynamically create a FormItem w/ various text boxes dynamically from
a click event including a delete button in each form item that will
allow the user to delete that specific instance of the object. I am
able to create the FormItem using createChild, but don't know how to
get destroyChild to work for a specific object. I am guessing you
must reference "this" when referring to the specific FormItem object,
but not sure of the correct syntax.
Note: In my code my add function calls a component I have created
(Start_New_Event.Components.Entry)
Here is what I have:
***********************
Main.mxml
**********************
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >
<mx:Script>
<![CDATA[
var rowArray : Object = new Array() ;
var counter : Number = 0 ;
private function addRow():Void
{
rowArray[counter] = Start_New_Event.Components.Entry
(formItem.createChild(Start_New_Event.Components.Entry, undefined,
null ) );
counter++;
}
public function deleteRow():Void{ //<-- this function does not work
if(rowArray[counter] != 0){
this.destroyChild(rowArray[counter -1] );
counter--;
}
}
]]>
</mx:Script>
<mx:Form>
<mx:Button label="Add" width="60" click="addRow();"/>
<mx:FormItem textAlign="left" id="formItem">
<mx:HBox>
<mx:TextInput id="txtRCAParticipants" width="150"/>
<mx:TextInput id="txtTitle" width="150"/
<mx:Button label="Delete" click="deleteRow();" />
</mx:HBox>
</mx:FormItem>
</mx:Form>
</mx:Application>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/