Remove child function

I have the following function to add movie clips to the stage...
I assume it is the correct way to add movieclips to the stage becuase it works.
function attachMovieClips(){
for (var i=0; i<list_array.length; i++)
{var mySelectFile:selectFile = new selectFile();
mySelectFile.name = "mySelectFile"+i;
mySelectFile.y = (mySelectFile.height + 10)*i;
addChild(mySelectFile);}}
attachMovieClips();
i need a function to remove all the attached movie clips...
I assume i need to use removeChild however everything i've tried hasn't worked...
i should think this is an easy problem if you understand AS3, sadly i don't, i'm not sure why i need to create a class to add a mc to the stage in the first place?... please can someone help... kind regards Jonathan

As you make things you could add them to an array. On these lines:
var removeLaterArray:Array = [];
then in your routine where you make things, you add:
removeLaterArray.push(mySelectFile);
and it any other functions that make things that you also want to remove at the same time, you add those to the array:
removeLaterArray.push(someOtherMovieClip);
At the time you want to remove them all, you would run around the array, and have the item's parent remove that item. Like this:
for(var i = 0;i<removeLaterArray.length;i++){
    var anItem:DisplayObject = removeLaterArray[i];
    anItem.parent.removeChild(anItem);
and perhaps:
removeLaterArray  = null;
to get rid of any lingering references to the objects.
There can be other issues though, like if each of your custom objects sets up its own listeners, ideally you would want to remove those listeners. And so perhaps your selectFile Class might have a dispose method, that removes its listeners and also removes itself:
public function dispose(){
    removeanylistenersImade();
    this.parent.removeChild(this);
I'm sure there are other alternate ways too. Overall I wouldn't worry too much about it, once you have a way that works for the situation you have.

Similar Messages

  • Need help removing child

    Sorry to bring problems but i am trying to learn some as3 and so far i can not resolve this situation ,,,,,,
    this is the script i am using ,,,,,,,,,,,,,,
    Ent.buttonMode = true;
    Bio.buttonMode = true;
    ent.addEventListener(MouseEvent.CLICK, goEnt);
    function goEnt (e:MouseEvent):void
    var new Ent:MovieClip = new firstIntro();
    this.addChild(newEnt);
    newEnt.x = 659;
    newEnt.y = 428;
    Bio.addEventListener(MouseEvent.CLICK, goBio);
    function goBio (e:MouseEvent):void
    var newBio:MovieClip = new bioIntro();
    this.addChild(newBio);
    newBio.x = 659;
    newBio.y = 428;
    the problem is that when i click on first button the Movie Clip does load ok but when i click on second button the first movie cliip is visible ,,,, i have try everything i have read here but no luck ,,,,,,, i want to learn how to remove first child and allow only the second child to show up ,,,,,,, i am looking forward to add more buttons so the remove child should be for multiple buttons ,,,,, i am learning and so far did purchase a online tutorial but did not help me with this situation ,,,, thank you all in advance ,,,,,

    Create a variable to hold a reference to any child object that is added to the display list, then when any given button is used to add a new movieclip to the display list, use removeChild to get rid if any existing movie clip that was added through the reference in the variable. After the new movie clip is added to the display list, add a reference to that movie clip to the variable so that it can be used when the next movie clip will be added.
    Ent.buttonMode = true;
    Bio.buttonMode = true;
    // create a variable to hold a reference to the currently added child, if any...
    var currentChild: MovieClip;
    ent.addEventListener(MouseEvent.CLICK, goEnt);
    function goEnt (e:MouseEvent):void
    var new Ent:MovieClip = new firstIntro();
    // remove any child object currently in the display list...
    if(currentChild != null) {
    removeChild(currentChild);
    this.addChild(newEnt);
    // put a reference to the added child to the variable...
    currentChild = newEnt;
    newEnt.x = 659;
    newEnt.y = 428;
    Bio.addEventListener(MouseEvent.CLICK, goBio);
    function goBio (e:MouseEvent):void
    var newBio:MovieClip = new bioIntro();
    // remove any child object currently in the display list...
    if(currentChild != null) {
    removeChild(currentChild);
    this.addChild(newBio);
    // put a reference to the added child to the variable...
    currentChild = newBio;
    newBio.x = 659;
    newBio.y = 428;

  • Remove child on the root timeline from within a movieclip

    Hi
    How do I remove a child from the root timeline from within a separate movieclip?
    I've tried
    MovieClip(parent).removeChild(mc1);
    But I get this error
    1120: Access of undefined property mc1.
    I could write a function in the root timeline that just removes child and then run that from within the movieclip but is there a better way?
    Thanks in advance.

    Thanks for replying.
    I asked on Kirupa but I couldn't access the site so I asked here.
    I guy answered with this
    MovieClip(parent).removeChild(MovieClip(parent).getChildByName("mc1"));
    It works fine, is this the best way to do it?
    Not sure if I understand what you meant?
    Just to be clear I have to movie clips on the stage mc1 and mc2 and i want to remove mc1 from within mc2's timeline.
    Thanks again

  • How to remove a function on the main timeline within a movie clip

    How do you remove a function that is coded on a frame in the main timeline from within a movie clip?  I tried this, but no dice:
    infoGraphicDisparity.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene);
    function fl_ClickToGoToScene(event:MouseEvent):void
        parent.removeEventListener (Event.ENTER_FRAME, parent["enterFrameHandler"]);
        MovieClip(this.root).gotoAndPlay("disparity");
    this is the event I am trying to remove:
    stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
    any help would be appreciated as always.
    Thanks!

    from any frame (that executes after enterFrameHandler is defined) in any display object in the display list
    stage.removeEventListener(Event.ENTER_FRAME, MovieClip(root).enterFrameHandler);

  • Help!how remove child's node in tree.

    I think remove child's node of tree in run times.
    thanks

    Hi!
    Try to look this:
    http://blogs.sun.com/winston/entry/creating_dynamic_table
    Maybe it will be helpful for You.
    Thanks,
    Roman.

  • Parent calling child function

    Hi,
    May i know how to call child function(layer 2) in parent(layer 1)?
    Layer 1 (Parent)
    function changeAction():void{
         changeColor();
    This method will give me the error -> Call to a possibly undefined method changeColor.
    Layer 2 (Child)
    function changeColor():void{
         trace("success");
    Thanks.

    You will need to assign an instance name to the child or have some reference to it for targeting it.  If you named the child "child1", then the parent function would be more like...
    function changeAction():void{
        child1.changeColor();

  • FR: Remove Gaps function

    *******Enhancement / FMR*********
    Brief title for your desired feature: Remove Gaps function
    How would you like the feature to work?
    Ability to remove all gaps between selected Timeline clips in a single step, either by:
    1. using a new user-customizable keyboard shortcut
    2. right-clicking the selection and clicking on a new 'Remove Gaps' option in the context menu.
    3. selecting 'Remove Gaps' from the 'Sequence' menu (having this option appear next to the 'Go to Gap' function would be a logical positioning)
    Gaps between clips on different tracks would also be removed, while leaving each clip on its respective track.
    Why is this feature important to you?
    Editing workflows often leave dozens of gaps between clips.  For example, a common editing workflow is to do a clip pre-selection using the Source Monitor to send subclips to the Timeline, and then grabbing clips from that selection to edit to music/etc.  Every clip removed leaves a gap behind, that quickly leaves things untidy.  Having to manually delete these gaps one by one, to clean up one's Timeline, is a tremendous time waster for something that could easily be achieved in a single step with a 'Remove Gaps' function!

    Jim Simon wrote:
    Yes, Pierre,  I checked them all.
    You checked every program out there in existence?  Right...
    Jim Simon wrote:
    It makes perfect sense for the simple fact that the selection is made.  You can't expect Premiere Pro to know when you made that selection by mistake and when you did it on purpose.  So it respects that selection, as is expected and desired.
    Clips get selected all of the time NOT because the users is choosing to select the clip(s) per se, but because it's a means to an end.  For example, a user wants to edit a clip's effects?  That user needs to select the clip so that it opens up in the ECW.  Requiring that the user actively deselects clips every single time, so that they don't delete them by mistake when they're completely out of view, ADDS steps that wouldn't be necessary if Premiere were smart enough to not allow unintentional changes to be made a completely unseen clip selection.
    Jim Simon wrote:
    how often do editors actually want to modify a completely hidden clip selection?
    It doesn't have to be completely hidden.  I will sometimes zoom out to select a range of clips, then zoom back in see the operation being performed.
    Are you just playing stupid, or do you actually still not get it Jim?  If a selection is partially visible, I said and will say again for the last time that all actions should work as usual.  My argument is only for when a clip selection is completely unseen, and therefore far too prone to accidental modification by a user that DOES NOT REALIZE that something was left selected.  Get it?  Arguying that Premiere shouldn't be improved in this regard because users shouldn't make this mistake in the first place is as stupid as saying that cars shouldn't have seatbelts and airbags because drivers shouldn't be getting into accidents.  And by the way, your reference to not wanting HAL for an NLE only goes to show how dumb you can get with your arguments.

  • Problem: Intermittant accesst to remove DVR function from work, plus unrelated(?) hub issue

    Hi folks.
    We have the DVR with media manager and multiroom and all that.  I love it, but two things are going on.
    1: I can sometimes, but rarely, get to remove DVR functions from the webpage. When I log in I can see  the caberbox status that tells me how many hours of recordingI have left. However, I don't see an icon on the left that lets me record or delete things, nor can i see anything when I click the DVR button from the cablebox status page.  Whats going on? Sometimes I can see it, but not often enough.
    2: When watching DVR'ed programs in the bedroom, occiasionaly we get a popup message that covers the screen saying something about losing connection to the hub or something like that. IT then stops us from watching the recorded program, and makes us go back again from the begining. Any idea what thats about?

    BDMacD wrote:
    Hi folks.
    We have the DVR with media manager and multiroom and all that.  I love it, but two things are going on.
    1: I can sometimes, but rarely, get to remove DVR functions from the webpage. When I log in I can see  the caberbox status that tells me how many hours of recordingI have left. However, I don't see an icon on the left that lets me record or delete things, nor can i see anything when I click the DVR button from the cablebox status page.  Whats going on? Sometimes I can see it, but not often enough.
    2: When watching DVR'ed programs in the bedroom, occiasionaly we get a popup message that covers the screen saying something about losing connection to the hub or something like that. IT then stops us from watching the recorded program, and makes us go back again from the begining. Any idea what thats about?
    There have been hub errors and other issues with HM DVR and I believe it is fixed with th 1.6.2 software that is being rolled out nationwide. There is a post about 1.6.2 that shows the remaining schedule of where and when. If you go to menu/ settings/ System Information, it will show you what version you have.
    Here is a link to that posting.
    http://forums.verizon.com/vrzn/board/message?board.id=FiOS_TV&thread.id=8917
    Message Edited by prisaz on 03-26-2009 05:10 PM

  • How to remove  child query link from parent query for RRI

    Hi Floks,
    Long back we have created one RRI report(which is having parent child relation).Currently i wanted to remove this link or relation (i.e remove child report) between them.
    I tried From  t-code RSBBS but i could n't.  Please give me some inputs to fix this.
    Regards,
    Satya.

    Hi Satya,
    In the TCode RSBBS ,did u try deleting the assignments itself ..........save it and transport it ...........
    Rgds
    SVU123

  • Removing child records

    Hi,
    I am using below code to delete the child records for a particular parent record in the Controller:
    But the problem is, it is going in the loop and says deleting records...but data is still present in detail table.
    Please help!
    if ("delete".equals(pageContext.getParameter(EVENT_PARAM)))
    MollyAMImpl am = (MollyAMImpl)pageContext.getApplicationModule(webBean);
    MollyUserDetailsVOImpl voChild = am.getMollyUserDetailsVO1();
    String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
    System.out.println("ROW Reference =="+rowReference);
    MollyUsersVORowImpl voRow = (MollyUsersVORowImpl)am.findRowByRef(rowReference);
    String parentID = "" + voRow.getId();
    System.out.println("The Id value to be removed from child table is "+ parentID);
    voChild.setWhereClause("");
    voChild.setWhereClause("ID =" + parentID);
    System.out.println("Child VO Query to execute : "+voChild.getQuery());
    voChild.executeQuery();
    System.out.println("Remove - Child Query was sucessfull");
    int childRecords = voChild.getRowCount();
    System.out.println("Remove - child records to delete: "+ childRecords);
    Row childRow=voChild.first();
    for(int i=1;i<=childRecords;i++)
    childRow.remove();
    System.out.println("Deleting child record "+ i);
    childRow=voChild.next();
    am.getTransaction().commit();
    System.out.println("committed.....");
    System.out.println("All child deleted successfully");
    }

    Hi Gyan,
    Thanks for the reply. Please find below SOP values. I have checked the Query, Ids is correct there...
    ROW Reference ==MollyAM.MollyUsersVO1:MollyUsersVO1{74}
    The Id value to be removed from child table is 74
    Child VO Query to execute : SELECT MollyUserDetailsEO.ID, MollyUserDetailsEO.PKG_NAME, MollyUserDetailsEO.PKG_CASE, MollyUserDetailsEO.CREATION_DATE, MollyUserDetailsEO.CREATED_BY, MollyUserDetailsEO.LAST_UPDATE_DATE, MollyUserDetailsEO.LAST_UPDATE_LOGIN, MollyUserDetailsEO.LAST_UPDATED_BY, MollyUserDetailsEO.DETAIL_ID FROM XXE_FXX_USER_DETAILS MollyUserDetailsEO WHERE (ID =74)
    Remove - Child Query was sucessfull
    Remove - child records to delete: 5
    Deleting child record 1
    Deleting child record 2
    Deleting child record 3
    Deleting child record 4
    Deleting child record 5
    committed.....
    All child deleted successfully

  • Parent function calling a child function with arguments

    Can anyone give examples of a parent function which has at least 1 parameter, and is invoked from the Form Behavior, which in turn , depending on data, invokes 2 or more child functions passing to these functions the same parameter that was passed in to it.
    I am getting 'Object required' and do not know what I am doing wrong. Please let me know if you've done it, and how you've referenced it , if they are BOTH functions. Thank you!

    The best way to do this is probably using delegates, but to do it directly you have to solve the circular dependency problem (as you have discovered). See
    http://en.wikipedia.org/wiki/Circular_dependency
    In case it is not clear to you how the Wikipedia article relates to your case, your files should look something like this:
    // Form1.h
    #include "Watch.h"
    ref class Form1: public Form
    public:
    void SomeMethod()
    // implementation
    private:
    void SomeHandler()
    Watch watchForm(this);
    watchForm.ShowDialog();
    // Watch.h
    ref class Form1; // declaration only
    ref class Watch: public Form
    public:
    Watch(Form1^ f1);
    private:
    Form1^ form1;
    void SomeMethod();
    // Watch.cpp
    #include "Watch.h"
    #include "Form1.h"
    Watch::Watch(Form1^ f1)
    form1 = f1;
    void Watch::SomeMethod()
    form1->SomeMethod();
    David Wilkinson | Visual C++ MVP

  • Forms Designer - Unable to remove Child Table from the form

    Hello,
    While testing adding additional attributes, I have assigned an additional child table to the form. However I am not able to remove it. I get an error message: "This version has been made active. Add/Update/Delete not allowed."
    I tried creating new version and making it active to remove 'active' status from the form I modified, but still getting the same error. What am I doing wrong? Thank you in advance.

    creating new version and making it active to remove 'active+'
    Make new version then remove child form and then make version active..
    You are making version active b4 removing child table.
    Don't change the sequence which I have written above.

  • Remove Child does clean momery?

    Hi.
    I know that if you remove childs previously added with addChild to the stage they tend to stick in memory and thus reducing performance. For instance if i use a for statement every time i want to populate a list and remove them while i close the list do they remain in memory and thus doing more add and remove of different childs would clutter the memory? Because every time i would create new childs and then add them with addChild so i presume they stick in memory.
    Is there a way to safely remove them so that i free up memory every time  i remove Childs?
    Thank you.

    Take a look at this wonderful article about Resource Management in AS3.
    http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html
    Regards,
    CaioToOn!

  • Weird add/remove child layout behavior

    I'm trying to build an an app that allows the user to toggle
    certain panels on and off. These panels are in Divider containers.
    It seems that at startup, when I remove and add a panel flex
    doesn't properly validate layout. For example 2 panels are added to
    a VDivided container. I then call removeChild on the second panel
    (at the bottom of the container), and the first panel then properly
    occupies all the visible space. When I add the second panel back,
    it is re-added but has not retained its original size and is
    instead compressed at the bottom. If I then remove the top panel
    and add it again, then remove the bottom panel and add it,
    everything works as I expect. It's almost like their is a one-time
    initialization not occurring somewhere. Here is the code sample I
    am using to demonstrate the problem:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" width="1000" height="800">
    <mx:VBox height="100%" top="0" left="0" right="0">
    <mx:ApplicationControlBar x="0" y="0" width="100%"
    height="58">
    <mx:CheckBox label="Panel 1" id="panel1CheckBox"
    selected="true" click="modifyViewPanel1()"/>
    <mx:CheckBox label="Panel 2" id="panel2CheckBox"
    selected="true" click="modifyViewPanel2()"/>
    </mx:ApplicationControlBar>
    <mx:VDividedBox x="0" y="0" width="100%" height="90%"
    id="vDivideBox">
    <mx:Panel width="100%" height="50%" layout="vertical"
    title="Panel 1" id="panel1">
    </mx:Panel>
    <mx:Panel width="100%" height="50%" layout="vertical"
    id="panel2" title="Panel 2">
    </mx:Panel>
    </mx:VDividedBox>
    </mx:VBox>
    <mx:Script>
    <![CDATA[
    private function modifyViewPanel1():void {
    trace("modifyView...");
    if (panel1.parent) panel1.parent.removeChild(panel1);
    if (panel1CheckBox.selected) {
    vDivideBox.addChildAt(panel1, 0);
    private function modifyViewPanel2():void {
    trace("modifyView...");
    if (panel2.parent) panel2.parent.removeChild(panel2);
    if (panel2CheckBox.selected) {
    vDivideBox.addChildAt(panel2,
    vDivideBox.getChildren().length);
    ]]>
    </mx:Script>
    </mx:Application>

    The properties you set with MXML tags are the initial values,
    they aren't used to reset the controls. They would have to be
    dynamic properties like width="{comp1.width/2}" for them to change
    as the program runs. Setting a component's width to "50%" just
    means it will initially be calculated to have 50% of the width of
    its parent. As the program runs the component's width can change
    which it what's happened.
    Removing a child only removes the component from the parent's
    display list. The component still exists and adding it back causes
    the parent to recalculate its layout. This means it may change the
    size of the children.
    You have a couple of choices. You can give the Panel a
    minHeight and the Divider will respect that. Or you can calculate
    the Panel's height, set it to that value, then add it back to the
    Divider.

  • How can remove child into file xml using J2ME

    i want to delete child from file xml using midlet but nothing is changed into file
    please help me
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package ajou;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.util.Vector;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    import javax.microedition.midlet.MIDlet;
    import org.kxml2.io.KXmlParser;
    import org.kxml2.kdom.Document;
    import org.kxml2.kdom.Element;
    import org.kxml2.kdom.Node;
    * @author -Manel-
    public class manelGO extends MIDlet {
    public void startApp() {
    try {
              //Open http connection
              HttpConnection httpConnection = (HttpConnection) Connector.open("http://localhost:8080/examples/users.xml");
                   //Initilialize XML parser
                   KXmlParser parser = new KXmlParser();
                   parser.setInput(new InputStreamReader(httpConnection.openInputStream()));
                   Document theDoc = new Document();
                   theDoc.parse(parser);
                   Element rootElement = theDoc.getRootElement();
    rootElement.removeChild(1);
              catch (Exception e) {
                   e.printStackTrace ();
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {
    }

    To achieve this you can use the bpelx:remove function: http://download.oracle.com/docs/cd/E12483_01/integrate.1013/b28981/manipdoc.htm#CIHJBJFD
    your assign will look like:
    <bpel:assign>
    <bpelx:remove>
    <target variable="person" query="/person/@per" />
    </bpelx:remove>
    </bpel:assign>
    Regards,
    Melvin

Maybe you are looking for

  • JSP error message

    I use Jdev3.1 and Oracle8.1.6 deploy locally to TOMCAT3.1 I got some problem: -JBO 26080 error while selecting entity for typepiece ORA-01002 fetch out of sequence -When I insert a new row an leave blank a mandatory attribute I got the following mess

  • HT5622 How do I check what version of ICLOUD CONTROL PANEL I have on Windows VISTA HP?

    Apple support says when using a Windows computer with VISTA, to insure the ICLOUD CONTROL PANEL is 2.1.2 or earlier.  How do I check what control panel I have on my HP to insure we are in compliance?  (Am having sync problems with calendar.) Thanks.

  • Raising Faults in a Sync Scenario.

    Hello PI experts, I really need an answer to this question, most of the answers i find out about this is all negative. 'PI can't do that w/o BPM' Scenario: SOAP<->PI<->RFC(sync) Problem: in case of application specific errors, RFC response will have

  • Not able to open BB App World through WiFi

    Hi All, I am Having BB Curve 9220 and Network which i'm using that is Vodafone. Previously i'm able to use applicaiton and able to open BB App world through wifi. But now i given my phone to service centre they update and now i'm not able open BB app

  • Error occurs when applying pre-install task of patch 9239089

    Error occurs when applying pre-install task of patch 9239089 ----------------------------------Pre-install Tasks-------------------------------------- 4. Use SQL*Plus to run the script: UNIX: $ sqlplus /nolog SQL> @$ORACLE_HOME/appsutil/admin/adgrant