Removing children

i have a movie clip container that i am dynamically adding
buttons to. i need to know how to remove all of the children from
my container movie clip. i need to remove all of them before i
re-populate the container with the new buttons.
i need a line of code that will remove all the children from
a specific movie clip. (ps- the amount of children varies)
any help would be greatly appreciated.

Just pass the MovieClip reference to the function. i.e.
killChildren(holder);
The function needs to be somewhere in scope. But you don't
need to use a
function -- you can simply use this if it suits you:
while(holder.numChildren > 0){holder.removeChildAt(0);}

Similar Messages

  • Adding and removing children with buttons

    So I've been following this tutorial (http://www.danfergusdesign.com/classfiles/oldClasses/VCB331-richMedia1/exercises/addingChi ldren.php) on how to add and remove children with buttons in order to create a popup box on the stage.
    The part I'm having trouble with is how I add the close button to the stage on top of the popup box.
    This is basically what I'm trying to do:
    Here's my code right now:
    var OrderPrepOnlineMenuInstance:OrderPrepOnlineMenu = new OrderPrepOnlineMenu();
    var mcOnStage:Boolean=false;
    loadOrderPrepOnlineBtn.addEventListener(MouseEvent.CLICK, loadMC);
    OrderPrepOnlineClose.addEventListener(MouseEvent.CLICK, removeMC);
    function loadMC(MouseEvent):void {
    addChild(OrderPrepOnlineMenuInstance);
    OrderPrepOnlineMenuInstance.x = 465;
    OrderPrepOnlineMenuInstance.y =230;
    mcOnStage=true;
    function removeMC(MouseEvent):void {
    if (mcOnStage ) {
    removeChild(OrderPrepOnlineMenuInstance);
    mcOnStage=false;

    Why not just make the close button part of the object you are adding.  You can assign it an event listener thru that object after it is created.

  • Remove children of a branchGroup

    Hi,
    I have created a 3D scenary with Java3D. My problem is:
    For example, I create a 3D scenary which has 4 cube and I want two cubes dessapear if I click a button.
    To obtain it I have thought that when I click the button, execute removeAllChilldren function to remove the branchGroup with the 4 cubes. After add a new BranchGroup with only 2 cubes.
    But I have had capabilities problems (no capability to remove children) when I use removeAllChilldren function, maybe because if a BranchGroup has been compiled, it isn't posible to use that function.
    Anybody knows how I can obtain it? An easier way?
    Thanks in advance.

    You have to set the capability bits before the branchgroup is compiled (usually during instanciation?), then you should be able to remove and add elements to your heart's content.

  • Removing children from List causes visual bug

    Hello,
    I'm new to Flex so I apologize if this is basic and trivial.
    I have a list that I'm using some databinding with some
    search results. After the initial search I need to clear out all of
    the children in the list before running the next search otherwise
    it just gets tacked onto the bottom. When I try running removeChild
    for all of the children nodes in the list it removes the items, but
    then does something to the visual display and leaves a giant gray
    box. I know that the new data is being loaded in as the scrollbar
    changes size to indicate that there are elements, but it's just all
    gray.
    Is there some sort of a re-draw function that needs to take
    place or is there an error with my method of clearing the
    contents?

    removeChild removes a DisplayObject from it's container.
    You seem to want to clean up the result list before you fetch
    new results.
    I assume you have the following:
    [Bindable]
    private var myList:ArrayCollection ;
    <mx:List dataProvider="{myList}" .../>
    Before you fetch your next set of results, clear myList.
    myList.removeAll() or whatever is appropiate.
    It is always best practice to manipulate the dataprovider for
    the visual
    controls. DataBinding will update the control as
    appropriate.

  • Problem removing children from within an event handler

    I'm trying to remove a movie clip from an onComplete handler.
    When I try to do this I get the following error
    "ArgumentError: Error #2025: The supplied DisplayObject must
    be a child of the caller."
    The point where my loader is complete is the time that I have
    to remove this movieclip.
    Would any body be able to tell me what the error means and
    help me with a way around it?
    Thanks
    dub

    You can always do it this way -- doesn't matter which display
    list the object is in.

  • Problem Removing Children

    I'm having trouble removing some preloader movieclips I have inserted via AS3. The message I get is:
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/removeChild()
    at btn5_fla::MainTimeline/thumbLoaded()
    for every preloader a loaded, except the last one.
    My code is:
    import caurina.transitions.*;
    var indexXML:XML;
    var columns:Number;
    var thumbWidth:Number;
    var thumbHeight:Number;
    var myThumbs:XMLList;
    var totalThumbs:Number;
    var preloader:LoaderAnim;
    var container:MovieClip;
    var xCounter:Number = 0;
    var yCounter:Number = 0;
    var xmlReq:URLRequest = new URLRequest("clientes.xml");
    var xmlLoader:URLLoader = new URLLoader();
    scrollbox.ch.client_info.autoSize = TextFieldAutoSize.LEFT;
    scrollbox.ch.client_info.htmlText = "";
    scrollbox.sb.visible = false;
    scrollbox.sb.alpha = 0;
    function urlLoaded(e:Event):void{
    indexXML = new XML(e.target.data);
    columns = indexXML.logos.@columns;
    thumbWidth = indexXML.logos.@width;
    thumbHeight = indexXML.logos.@height;
    myThumbs = indexXML.logos.*;
    totalThumbs = myThumbs.length();
    scrollbox.ch.client_info.htmlText += indexXML.intro;
    createContainer();
    callThumbs();
    function createContainer():void{
    container = new MovieClip();
    scrollbox.ch.addChild(container);
    container.y = scrollbox.ch.client_info.height + scrollbox.ch.client_info.y + 20;
    function callThumbs():void{
    for(var i:Number = 0; i<totalThumbs; i++){
    var thumbURL = myThumbs[i].@thumb;
    trace("Loading "+thumbURL);
    var thumbLoader = new Loader();
    thumbLoader.load(new URLRequest(thumbURL));
    thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
    thumbLoader.x = (thumbWidth+40)*xCounter;
    thumbLoader.y = (thumbHeight+40)*yCounter;
    if (xCounter+1 < columns){
    xCounter++;
    }else {
    xCounter=0;
    yCounter++;
    preloader = new LoaderAnim();
    preloader.name = "preloader"+i;
    trace(preloader.name);
    preloader.x = thumbLoader.x+30;
    preloader.y = thumbLoader.y+30;
    container.addChild(preloader);
    function thumbLoaded(e:Event):void{
    var thb:Loader = Loader(e.target.loader);
    container.addChild(thb);
    if(scrollbox.ch.height<scrollbox.masker.height){
    scrollbox.sb.visible = false;
    }else{
    scrollbox.sb.visible = true;
    Tweener.addTween(scrollbox.sb, {alpha:1, time:1});
    container.removeChild(preloader);
    xmlLoader.addEventListener(Event.COMPLETE, urlLoaded);
    xmlLoader.load(xmlReq);

    import caurina.transitions.*; 
    var indexXML:XML;
    var columns:Number;
    var thumbWidth:Number;
    var thumbHeight:Number;
    var myThumbs:XMLList;
    var totalThumbs:Number;
    var i:uint=0;
    var preloader:LoaderAnim;
    var container:MovieClip;
    var xCounter:Number = 0;
    var yCounter:Number = 0;
    var xmlReq:URLRequest = new URLRequest("clientes.xml");
    var xmlLoader:URLLoader = new URLLoader();
    scrollbox.ch.client_info.autoSize = TextFieldAutoSize.LEFT;
    scrollbox.ch.client_info.htmlText = "";
    scrollbox.sb.visible = false;
    scrollbox.sb.alpha = 0;
    function urlLoaded(e:Event):void{
    indexXML = new XML(e.target.data);
    columns = indexXML.logos.@columns;
    thumbWidth = indexXML.logos.@width;
    thumbHeight = indexXML.logos.@height;
    myThumbs = indexXML.logos.*;
    totalThumbs = myThumbs.length();
    scrollbox.ch.client_info.htmlText += indexXML.intro;
    createContainer();
    callThumbs();
    function createContainer():void{
    container = new MovieClip();
    scrollbox.ch.addChild(container);
    container.y = scrollbox.ch.client_info.height + scrollbox.ch.client_info.y + 20;
    function callThumbs():void{
    //for(var i:Number = 0; i<totalThumbs; i++){
    var thumbURL = myThumbs[i].@thumb;
    trace("Loading "+thumbURL);
    var thumbLoader = new Loader();
    thumbLoader.load(new URLRequest(thumbURL));
    thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
    thumbLoader.x = (thumbWidth+40)*xCounter;
    thumbLoader.y = (thumbHeight+40)*yCounter;
    if (xCounter+1 < columns){
    xCounter++;
    }else {
    xCounter=0;
    yCounter++;
    preloader = new LoaderAnim();
    preloader.name = "preloader"+i;
    trace(preloader.name);
    preloader.x = thumbLoader.x+30;
    preloader.y = thumbLoader.y+30;
    container.addChild(preloader);
    function thumbLoaded(e:Event):void{
    var thb:Loader = Loader(e.target.loader);
    container.addChild(thb);
    if(scrollbox.ch.height<scrollbox.masker.height){
    scrollbox.sb.visible = false;
    }else{
    scrollbox.sb.visible = true;
    Tweener.addTween(scrollbox.sb, {alpha:1, time:1});
    container.removeChild(preloader);
    i++;
    if(i<totalThumbs){
    callThumbs();
    xmlLoader.addEventListener(Event.COMPLETE, urlLoaded);
    xmlLoader.load(xmlReq);

  • Dynamically removing Children

    I have 36 images in a movie clip. Inside of that movie clip
    there are 36 other movie clips containing one separate image. I
    have figured out how to click on them and add it to the stage. BUT
    i can figure out how to get them to remove when another image is
    clicked. (ex. i click on image 1 it will appear on stage but when i
    click image 2 it show image 2 on top of image 1.) the thing is i
    dont want to have to click on the images in order. I so if any
    image is clicked the one showing on stage will automatically
    disappear. my code is attached. any help will be tremendously
    appreciated.

    Based on having seen the code, the problem I see with the
    array is that I don't know that you can dynamically declare
    objects. The problem is all of your awards are different MovieClips
    which means each needs to be declared as in:
    var award1:Award1 = new Award1();
    var award2:Award2 = new Award2();
    I could be wrong, but from my testing I was unable to do
    dynamic declarations as in the example attempt below.
    If it was me I would create an award MovieClip and have each
    award image in a frame (with a frame label for each award). This
    way you only have to add one award MovieClip to the stage and
    button code for that one award MovieClip. This would mean some
    decent adjustments to the existing code, which I may be able to
    show later, but I am pretty busy for now.

  • Coding hierarchy with as3 and removing children

    To give a brief background of what's going on here.  I am building a personal site where I have a navigation, and I have other subnavs inside of certain pages.  Such as if I go to "work" inside of work i have "motion", "web" & "print".  Here is some example code of one button on the navigation:
    nav_mc.personalbtn_mc.addEventListener(MouseEvent.CLICK, buttonClick2);
    function buttonClick2(event:MouseEvent):void {
    gotoAndStop("personal");
    function workss_mcExists():void {
    if (workss_mc.stage!=null) {
    trace("YES workss does exist");
    removeChild(workss_mc);
    } else {
    trace("NO workss does not exist");
    workss_mcExists();
    function motionss_mcExists():void {
    if (motionss_mc.stage!=null) {
    trace("YESdudemar");
    removeChild(motionss_mc);
    } else {
    trace("NO");
    motionss_mcExists();
    function workExists():void {
    if (work_mc.stage!=null) {
    trace("YES");
    removeChild(work_mc);
    } else {
    trace("NO");
    workExists();
    function objectExists():void {
    if (workss_mc.stage!=null) {
    trace("YES");
    removeChild(workss_mc);
    } else {
    trace("NO");
    objectExists();
    function home_mcExists():void {
    if (home_mc.stage!=null) {
    trace("YESdudemar");
    removeChild(home_mc);
    } else {
    trace("NO");
    home_mcExists();
    function workpersonalExists():void {
    if (workpersonalss_mc.stage!=null) {
    trace("YES");
    removeChild(workpersonalss_mc);
    } else {
    trace("NO");
    workpersonalExists();
    It seems to me that actionscript will not read all the way down to the bottom when looking for objects.  For example: The first if statement where it's asking if workss_mc exists or not, that will work if it's at the top, but if I move it down to the bottom it will not work.  Does anyone have any insight of how to fix this or work around it?
    Thanks in advance!

    Let me clear this up detailed for you.
    When I click "WORK" everything loads correctly but it produces this error:
    Error #1009: Cannot access a property or method of a null object reference.
    at SILVERCOLLECTIVEv11cs4_fla::MainTimeline/motionss_mcExists()
    at SILVERCOLLECTIVEv11cs4_fla::MainTimeline/buttonClick1()
    After that I will be in the "WORK" page,  I have a subnav on that page.  I then load Motion {motionss_mc}. 
    Then I will click on another page in the nav (personal works correctly) so I will click on "Skills" when I click skills for some reason it's not calling the function to remove motionss_mc which is currently loaded.
    Here is the code for work, personal, and skills.
    When I click skills it produces this error code:
    Error #1009: Cannot access a property or method of a null object reference.
    at SILVERCOLLECTIVEv11cs4_fla::MainTimeline/home_mcExistss()
    at SILVERCOLLECTIVEv11cs4_fla::MainTimeline/buttonClick3()
    When I click personal it produces this:
    YESdudemar motion ss does exist
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at SILVERCOLLECTIVEv11cs4_fla::MainTimeline/workss_mcExistsp()
    at SILVERCOLLECTIVEv11cs4_fla::MainTimeline/buttonClick2()
    nav_mc.workbtn_mc.addEventListener(MouseEvent.CLICK, buttonClick1);
    function buttonClick1(event:MouseEvent):void {
    gotoAndStop("work");
    motionss_mcExists();
    home_mcExists();
    unimetal_homeref_mcExists();
    motion_mcExists();
    workpersonalssExists();
    workpersonalExists();
    printss_mcExists();
    workss_mcExists();
    work_mcExists();
    function motionss_mcExists():void {
    if (motionss_mc.stage!=null) {
    trace("YESdudemar motion ss does exist");
    removeChild(motionss_mc);
    } else {
    trace("NO motionSS does not exist");
    function home_mcExists():void {
    if (home_mc.stage!=null) {
    trace("YESdudemar home exists");
    removeChild(home_mc);
    } else {
    trace("NO HOme does not exist");
    function work_mcExists():void {
    if (work_mc.stage!=null) {
    trace("YESdudemar work exists");
    removeChild(work_mc);
    } else {
    trace("NO work does not exist");
    function workss_mcExists():void {
    if (workss_mc.stage!=null) {
    trace("YESdudemar workss exists");
    removeChild(workss_mc);
    } else {
    trace("NO workss does not exist");
    function unimetal_homeref_mcExists():void {
    if (unimetal_homeref_mc.stage!=null) {
    trace("YESdudemar unimetalhomeref exists");
    removeChild(unimetal_homeref_mc);
    } else {
    trace("NO home ref does not exist");
    function motion_mcExists():void {
    if (motion_mc.stage!=null) {
    trace("YES motion exists");
    removeChild(motion_mc);
    } else {
    trace("NO motion_mc does not exist");
    function workpersonalssExists():void {
    if (workpersonalss_mc.stage!=null) {
    trace("YES workpersonallsss exists");
    removeChild(workpersonalss_mc);
    } else {
    trace("NO work personalss does not exist");
    function workpersonalExists():void {
    if (workpersonal_mc.stage!=null) {
    trace("YES work personal does exist");
    removeChild(workpersonal_mc);
    } else {
    trace("NO work personal does not exist");
    function printss_mcExists():void {
    if (printss_mc.stage!=null) {
    trace("YESdudemar printss does exist");
    removeChild(printss_mc);
    } else {
    trace("NO PRINTss_MC does not exist");
    nav_mc.personalbtn_mc.addEventListener(MouseEvent.CLICK, buttonClick2);
    function buttonClick2(event:MouseEvent):void {
    gotoAndStop("personal");
    motionss_mcExistsp();
    workss_mcExistsp();
    work_mcExistsp();
    home_mcExistsp();
    workpersonalExistsp();
    workpersonalssExistsp();
    unimetal_homeref_mcExistsp();
    printss_mcExistsp();
    motion_mcExistsp();
    function motionss_mcExistsp():void {
    if (motionss_mc.stage!=null) {
    trace("YESdudemar motion ss does exist");
    removeChild(motionss_mc);
    } else {
    trace("NO motion ss does not exist");
    function motion_mcExistsp():void {
    if (motion_mc.stage!=null) {
    trace("YES motion exists");
    removeChild(motion_mc);
    } else {
    trace("NO motion_mc does not exist");
    function printss_mcExistsp():void {
    if (printss_mc.stage!=null) {
    trace("YESdudemar printss does exist");
    removeChild(printss_mc);
    } else {
    trace("NO PRINTss_MC does not exist");
    function unimetal_homeref_mcExistsp():void {
    if (unimetal_homeref_mc.stage!=null) {
    trace("YESdudemar unimetal does exist");
    removeChild(unimetal_homeref_mc);
    } else {
    trace("NO home ref does not exist");
    function workpersonalssExistsp():void {
    if (workpersonalss_mc.stage!=null) {
    trace("YES work personalss does exist");
    removeChild(workpersonalss_mc);
    } else {
    trace("NO work personalss does not exist");
    function workpersonalExistsp():void {
    if (workpersonal_mc.stage!=null) {
    trace("YES work personal does exist");
    removeChild(workpersonal_mc);
    } else {
    trace("NO work personal does not exist");
    function workss_mcExistsp():void {
    if (workss_mc.stage!=null) {
    trace("YES workss does exist");
    removeChild(workss_mc);
    } else {
    trace("NO workss does not exist");
    function work_mcExistsp():void {
    if (work_mc.stage!=null) {
    trace("YES work_mc exists");
    removeChild(work_mc);
    } else {
    trace("NO work_mc does not exist");
    function home_mcExistsp():void {
    if (home_mc.stage!=null) {
    trace("YESdudemar home-mc does exist");
    removeChild(home_mc);
    } else {
    trace("NO home_mc does not exist");
    nav_mc.skillsbtn_mc.addEventListener(MouseEvent.CLICK, buttonClick3);
    function buttonClick3(event:MouseEvent):void {
    gotoAndStop("skills");
    home_mcExistss();
    workExistss();
    workss_mcExistss();
    workpersonalssExistss();
    workpersonal_mcExistss();
    motionss_mcExistss();
    unimetal_homeref_mcExistss();
    printss_mcExistss();
    motion_mcExistss();
    function motion_mcExistss():void {
    if (motion_mc.stage!=null) {
    trace("YES motion exists");
    removeChild(motion_mc);
    } else {
    trace("NO motion_mc does not exist");
    function printss_mcExistss():void {
    if (printss_mc.stage!=null) {
    trace("YESdudemar printss_mc exists");
    removeChild(printss_mc);
    } else {
    trace("NO PRINTss_MC does not exist");
    function unimetal_homeref_mcExistss():void {
    if (unimetal_homeref_mc.stage!=null) {
    trace("YESdudemar unimetal does exist");
    removeChild(unimetal_homeref_mc);
    } else {
    trace("NO home ref does not exist");
    function workpersonalssExistss():void {
    if (workpersonalss_mc.stage!=null) {
    trace("YES work personalss exists");
    removeChild(workpersonalss_mc);
    } else {
    trace("NO work personalss does not exist");
    function home_mcExistss():void {
    if (home_mc.stage!=null) {
    trace("YESdudemar home does exist");
    removeChild(home_mc);
    } else {
    trace("NO home does not exist");
    function workExistss():void {
    if (work_mc.stage!=null) {
    trace("YES work exists");
    removeChild(work_mc);
    } else {
    trace("NO work does not exist");
    function workss_mcExistss():void {
    if (workss_mc.stage!=null) {
    trace("YES workss_mc does exist");
    removeChild(workss_mc);
    } else {
    trace("NO workss does not exist");
    function workpersonal_mcExistss():void {
    if (workpersonal_mc.stage!=null) {
    trace("YES work personal does exist");
    removeChild(workpersonal_mc);
    } else {
    trace("NO work personal does not exist");
    function motionss_mcExistss():void {
    if (motionss_mc.stage!=null) {
    trace("YESdudemar motionss does exist");
    removeChild(motionss_mc);
    } else {
    trace("NO motionss does not exist");

  • How remove childrens in SimpleTreeData?

    subj

    Hello Gorbunov,
    I assume you've looked at the docs; SimpleTreeData is just that. A DataObject-subclass with a simple implementation for building tree structures. However, managing those tree structures is a separate issue. The various proxies provide means for displaying parts of the tree, if that would suffice for you.
    I build a tree for use in an hGrid which contains approximately 150,000 elements. I find that the necessity of building a SimpleTreeData to be time-consuming and heavy on memory usage. Granted, once in memory, the hGrid functions fabulously.
    Sorry I can't help, but I, too, am interested in the further developments of SimpleTreeData and/or related tree DataObjects. Are these DataObjects going to be updated to reflect the new Network Data Model components in Oracle 10g? Binding the data to a SQL "start with ... connect by" query would be great.
    On the proxy side, the ability to display multiple paths through the tree would also be wonderful benefit.
    Thanks for any input, UIX team.
    joe

  • How do I remove a child from the stage using a button click?

    I have a movieclip that requires Play, Pause, Forward and Back buttons. The movieclip has actionscript at various frames to load movieclips from the library and repeat them.
    I have tried using a timeline scrubber but it does not trigger the actionscript when scrubbing, only when the movie plays normally.
    My possible solution is to create Fwd and Back buttons that can go to specific frames where key animations will begin.
    I need to develop actionscript that will remove Children when the user clicks Back.
    This is how I am loading several movieclips along the timeline from my library:
    var shpA1:arSHPp1;
    function attachAR1 () {
      shpA1 = new arSHPp1 ();
      shpA1.x = -30;
      shpA1.y = 18;
      addChild (shpA1);
    //the interval is used to repeat the animation to represent continuous flow on a diagram
    var myInterval1:uint = setInterval (attachAR1, 500);
    This what I have tried so far (not working at all - no errors or trace):
    function remChild1(event:MouseEvent) :void {
        if(shpA1.stage)
            trace("arSHPp1 is in display list");
            shpA1.parent.removeChild(shpA1);
            shpA1 = null
        else
            trace("arSHPp1 isn't in display list");

    I did try that but it would not remove the child.
    i appreciate your help though.
    I am also trying to determine if a child is on the stage and if it is, remove it. I have created a button that will jump back on the timeline and the mc's that were loaded after this point in time.
    This looks like it should work. It doesn't give me any errors but the mc remains on the stage.
    var remMC;
    if (getChildByName("mc2") != null) {
      removeChild(mc2);

  • @Remove help in IF statement

    Hi,
    I have a Parent named 'Total Gen' which has a bunch of children. I need the calc to run on FY09:FY29 AND all the bottom level members of 'Total Gen' except I need to exclude a member named 'Toll'. How do I properly write that in a IF statement?
    IF(@ISMBR(&StartYearPlus01:&StartYearPlus19) AND @REMOVE(@RELATIVE("Total Gen",0), @LIST("Toll")))
    Error:
    Error: 1200354 Error compiling formula for [Budget] (line 22): expected type [BOOLEAN] found [MEMBER] ([@REMOVE]) in function []
    Thanks

    Yes, CL is right, as always :)
    We can use @REMOVE in FIX.
    Just to add some info:
    The @REMOVE() function removes values or members in one list from another list.
    Syntax @REMOVE (list1, list2)
    Example: In the Sample Basic database,
    @REMOVE(@CHILDREN(East),@LIST("New York",Connecticut))
    returns Massachusetts, Florida, New Hampshire.
    Cheers...!!!

  • Bug or feature: possible to remove a child from unmodifiableChildren

    with kind of pathological code, though, see below ; - ) The trick is to add it to a parent which allows child list modifications, then internals silently reparent the child (same as swing Container add does).
    Question is, should (could?) internal protect their children better? Or maybe more basic: why does Parent expose the children list at all? Internally, it's rarely used. What would client code do with it?
    (a related discussion - maybe missing api to detect if a subclass of Parent allows modification of its child list: Scene root and Parent subclasses
    Cheers
    Jeanette
    public class UnmodifiableChildListRemove extends Application {
        public static void main(String[] args) {
            Application.launch(args);
        @Override
        public void start(Stage primaryStage) throws Exception {
            final HBox hBox = new HBox();
            final TextBox textBox = new TextBox(20);
            textBox.setPromptText("Prompt one");
            Button button = new Button("Click");
            button.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent event) {
                    hBox.getChildren()
                            .add(textBox.getChildrenUnmodifiable().get(0));
            hBox.getChildren().addAll(textBox, button);
            Scene scene = new Scene(hBox);
            primaryStage.setScene(scene);
            primaryStage.setVisible(true);
    }

    Richard Bair wrote:
    Yep, that's by design. The alternative (which we did for a time) of simply failing when a child is added to two parents fails miserably in a declarative-with-bind use case.
    Hmm ... not quite sure if I like that.
    Maybe I wasn't clear enough: my point is not about the silent reparenting if that would be valid modification (aka: doable by public api), that is both old and new parent have a public getChildren() to add/remove. It's about the illegal removal from the old (which doesn't allow public child list modification).
    Combined with the requirements in the other thread, it feels like a bit of missing api to publicly be able to distinguish child-modifiable parents from those that don't allow it.
    Something raw thinking:
    // on parent
    * A read-only property denoting whether this Parent allows
    * remove/add of children. 
    public boolean allowsChildListModification() {
        return false;
    * Returns an ObservableList of this Parent's children. If 
    * !allowsChildListModification this is an unmodifiable list
    * which will throw SomeException on attempts to add/remove, 
    * otherwise the list can be used to add/remove children.
    public ObservableList<Node> getChildren() {
      * Sets the node's parent to newParent. If the node already has
      * a parent, it's removed from the old if child list modifications
      * are allowed on both old and new parent.
      * If not ... (either fail silently or throw an IllegalState)
    void reparent(Node node, Parent newParent) {
         if (node.getParent() != null) {
              // either let the unmodifiable do the throwing job
              //node.getParent().getChildren().remove(node);
              // or check if allowed and act accordingly
              if (!node.getParent().allowsChildListModification()) {
                return;
    }You already know that I don't like exposing the modifiable lists at all, would prefer cover methods - but that's another story ; - )
    As for why Parent exposes the immutable list of children -- this is so you can walk the scene graph, which is very useful for tools and frameworks and other such kinds of code that people want to write.ahh ... good point, thanks!
    CU
    Jeanette

  • Removing items from memory using loop

    The following for loop removes children from their parent if
    they're in the display list. It works correctly, but I also want to
    remove each child from memory with the same loop. I can't get it to
    work correctly however.

    I have tried multiple items in the loop to set each child to
    null before or after it's removed.
    Here are some:
    this.child = null;
    var target = this.getChildAt(0);
    target = null;

  • Accessing children by index

    if I create a symbol, go to the linkage window, set the
    symbol's class name to myClass (which extends sprite), set it's
    base class to Sprite, then create an instance of myClass in AS3, my
    instance already has a child, of type shape, which presumably is
    just an instance of my symbol.
    this seems very problematic. if I want to then add and remove
    children using indices, everything will be off by one (or more?
    or, what if I at some point addChildAt(0)? then things get
    worse
    am I doing something wrong? should my symbol-extended objects
    begin life w/ zero children?
    if not, does that mean I should just stores my children in a
    backing array and manipulate that? or do it strictly by obj
    reference, as in removeChild(ref)?
    thanks

    that may cause some unexpected issue because it's not really
    a sprite and it's not a movieclip.
    anyway, each object created in the authoring environment has
    a graphic child object of some sort. that shouldn't cause any
    problems and doesn't interfere with accessing other child object
    types once you recognize the shape is a child object.

  • Remove Child?

    Can someone tell me how to remove a child.  I’ve composed an SWF that serves as a menu for launching other SWFs.  I used the following script to program the menu buttons.  When I want to return I’m currently using this script to reload the Menu file, which can be used to load another SWF.  You may see where this is going.  Because I’m just stacking children on top of each other the play rate bogs down.  If someone could tell this poor soul how to remove children when I return to the menu I would be eternally grateful. 
    BTN_Name.addEventListener(MouseEvent.CLICK, Name);  
    function Name(event:MouseEvent):void
    {   event.stopPropagation();
         var LOAD:Loader = new Loader(); addChild(LOAD);
         var url:URLRequest = new URLRequest("FileName.swf");
         LOAD.load(url);

    Thanks for your advice and sorry for my tardy response.  My course began this week and I've been swamped.
    I understand that the command I need is removeChild, however I'm a novice programmer and I don't know how to compose the script.  For instance, with the script above would I just write "removeChild(LOAD); into the last frame of the child file?  Would I need additional script like var LOAD:Loader = new Loader(); and if so where would I put it? 
    Sorry to be a pest; I'm sure these are tenderfoot questions, but that's what I am.

Maybe you are looking for

  • Internal 500 error while accessing TFS web site

    Hi all, I have installed & configured Team Foundation Server 2013 & SharePoint Foundation 2013 in my environment. I am facing an issue whenever I try to open the TFS site like "https://nc1vwstfs.ranchi.com/tfs". I am getting "HTTP 500 Internal Server

  • How do I get my security questions if I forgot them?

    If I forgot my security questions, could I send the answers to my email? Or how would I get them? I forgot the answers.

  • Where does Spotlight search??

    I have a file located in ~/Library/Favorites/. If I search (Cmd-F) for the filename Spotlight will find the file if my search starts in ~/Library/Favorites/ or ~/Library/ but not if my search starts in ~ or "This Mac" What's the deal? Is this some Pr

  • SunOne 6.1 HTTP4044 error with sun one web server cluster

    use sun one web server 6.1 sp4 makeup cluster,transfer configure file have HTTP 4044 error.the /opt/SUNWwbsvr/https-admin/logs/error file message are: failure ( 4646): for host x.x.x.x trying to POST /https-x.x.x.x/admin/clxfer, cgi_scan_headers repo

  • Help, don't know what to do

    I just installed the ipod itunes and i plugged it in and it downloaded all pics and songs, but now i want to eject the ipod to disconnect and when I push the eject it says "cannot eject it contains files being used in another application" what do I d