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.

Similar Messages

  • Dynamically removing a component button...

    Sorry if this question sounds stupid/easy, but I'm blanking.
    How do I use AS to dynamically remove a component button that was
    dragged out onto the stage?...
    Thanks!...

    quote:
    Originally posted by:
    kglad
    you caused that problem by doing something to the button's
    bounding box and/or loading your finalexam.swf into another swf.
    I don't know what I would have done to the bounding box. I
    just put the component on the stage and changed the theme color of
    it - that's all...
    As far as the final exam loading into another .swf, that's
    true. There's one "main" .swf that is the basic navigational shell
    for the course (the top/bottom of the course). Then all the "pages"
    of the course load into the big main window of the navigational
    shell...
    ...would that be what's causing it? How come? Is there a way
    to fix it???

  • Can I dynamically remove vi's.

    Is it possible to dynamically remove vi's? It does not seem possible with the vi-server-functions.

    If you dynamically load a VI, you can dynamically remove it by closing the
    VI reference.
    If it's a VI that has been loaded because it is part of another VI you
    cannot unload it while the parent remains in memory.
    I've never had to close a VI that has been arbitrarily loaded by the user,
    but I think that you cannot have a VI in memory if its front panel is
    closed, it is not running and it is not a child of another loaded VI. Hence
    I think you can close such VIs by closing their window, which is an
    available property.
    casimir wrote in message
    news:[email protected]..
    > Is it possible to dynamically remove vi's? It does not seem possible
    > with the vi-server-functions.

  • 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.

  • Problem creating dynamic component children with RestoreState of JSF 1.2

    Hello everybody,
    With JSF 1.1, it was possible to create children of a component dynamically in the constructor of a component.
    But now, with JSF 1.2, there is an issue with the RestoreState as a new instance of each component of the tree is created.
    Does someone has an idea on how to solve this issue?
    One possibility is to create the children not in the component, but in the renderer of the component.
    But I'm not really convinced of this solution...
    Thank you in advance.
    bgOnline

    You can create a new component dynamically in the method setParent() according to the following code snippet:
    public void setParent(UIComponent parent) {
    if (parent != null) {
    List<UIComponent> children = parent.getChildren();
    Application application = FacesContext.getCurrentInstance().getApplication();
         componentLabel = (HtmlOutputLabel) application
         .createComponent(HtmlOutputLabel.COMPONENT_TYPE);
         componentLabel.setTransient(true);
         children.add(componentLabel);
         } else if (parent == null) {
         if (componentLabel != null) {
         List<UIComponent> children = getParent().getChildren();
              children.remove(componentLabel);
              super.setParent(parent);
         }

  • 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);}

  • Dynamically add Children Link Element

    Hi,
    I'm trying to dynamically add a children element, a link, but the action binding refuses to work ...
    I've created a custom jsf component, that does nothing at all.
    For example, one would use it like:
    <my:nothing></my:nothing>So my UI class would have the following methods:
    public void encodeBegin(FacesContext context) throws IOException {
    public void encodeEnd(FacesContext context) throws IOException {
    }The tld file is created, the tag class is working. All the component is working properly.
    Now I want to add a link as a child component, but I wat to do it programatically, so I changed the encodeBegin method of my custom ui class:
    import javax.faces.el.ValueBinding;
    import com.sun.faces.util.Util;
    import javax.faces.el.MethodBinding;
    import javax.faces.component.UICommand;
    import javax.faces.component.html.HtmlCommandLink;
    import com.sun.faces.taglib.html_basic.CommandLinkTag;
    public void encodeBegin(FacesContext context) throws IOException {
              String myLinkId = "idMyLink";
              String myLinkValue = "myLink:Value";
              String myLinkStyle = "color:green;";
              String myLinkAction = "backup";
              HtmlCommandLink myLink = new HtmlCommandLink();
              myLink.setParent(this);
              myLink.setId( myLinkId );
              if (CommandLinkTag.isValueReference( myLinkValue )) {
                   ValueBinding vb = Util.getValueBinding( myLinkValue );
                   myLink.setValueBinding("value", vb);
              } else {
                   myLink.setValue( myLinkValue );
              if (CommandLinkTag.isValueReference( myLinkStyle )) {
                   ValueBinding vb = Util.getValueBinding( myLinkStyle );
                   myLink.setValueBinding("style", vb);
              } else {
                   myLink.setStyle( myLinkStyle );
              if(myLinkAction!=null) {
                   if (CommandLinkTag.isValueReference( myLinkAction )) {
                        System.err.println("Id="+myLinkId+":TRUE:getAccao:isValueReference:"+myLinkAction);
                        MethodBinding vb = getFacesContext().getApplication().createMethodBinding(myLinkAction, null);
                        myLink.setAction(vb);
                   } else {
                        System.err.println("Id="+myLinkId+":FALSE:getAccao:isValueReference:"+myLinkAction);
                        final String outcome = cNfo.getAccao();
                        MethodBinding vb = Util.createConstantMethodBinding( myLinkAction );
                        myLink.setAction(vb);
              myLink.encodeBegin(getFacesContext());
              myLink.encodeEnd(getFacesContext());
    }This seems to work, but not quite ... the link appears as expected, the value references for value and style are correctly passed, but the action doesn't work at all.
    For example if I change to:
    String myLinkValue = "#{mybean.linkText}";And I have the following method created on my managed bean:
         public String getLinkText() {
              return "This is myLink Text!";
         }Is successfully calls and retrieves the value from the method. Same happens to the style property.
    Now for the action, if I change to:
    String myLinkAction = "#{mybean.doMyLinkAction}";And I have the following method created on my managed bean:
         public String doMyLinkAction() {
              return "backup";
         }The result is nothing ... I mean the method is not called at all. The "backup" is properly defined on my "faces-config.xml":
       <navigation-rule>
          <from-view-id>/testPage.jsp</from-view-id>
          <navigation-case>
             <from-outcome>yes</from-outcome>
             <to-view-id>/yes.jsp</to-view-id>
          </navigation-case>
          <navigation-case>
             <from-outcome>no</from-outcome>
             <to-view-id>/no.jsp</to-view-id>
          </navigation-case>
          <navigation-case>
             <from-outcome>backup</from-outcome>
             <to-view-id>/backup.jsp</to-view-id>
          </navigation-case>
       </navigation-rule>If I create the link manually on the web page:
    <h:commandLink id="myLinkManual" value="Manually Created Link" style="" action="#{mybean.doMyLinkAction}"/>It does work (the backup.jsp page is shown), so the methods are properly configured, only the action binding does not work.
    Wether I use a string "backup" or a reference "#{mybean.doMyLinkAction}" I cannot make it work.
    On the console I get the following results, for each value I test (string "backup" or reference "#{mybean.doMyLinkAction}"):
    Id=idMyLink:TRUE:getAccao:isValueReference:backup
    Id=idMyLink:FALSE:getAccao:isValueReference:#{mybean.doMyLinkAction}So the "if (CommandLinkTag.isValueReference( myLinkAction )) {" is working properly ... that just leaves me with the action method binding instructions ...
    Why don't they work?
    Any Help Appreciated ... Thanks in Advance!

    c'mon guys ... can anyone test this and help me out?
    Pleeeeeease ... I'm really needing this working out.
    Thanks

  • 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.

  • Dynamic removing of Value Nodes

    Hi,
    in my application I create Value Nodes and Value Attributes dynamically.
    How can I remove this Value Nodes and Attributes again dynamically?
    Regards,
    Eva

    Eva,
    The only way is to completely reset context:
    wdContext.reset(false);
    This will remove all dynamically created nodes / attributes. You have to recreate structure afterwards (obviously, without node you were actually "removing")
    Valery Silaev
    EPAM Systems
    http://www.NetWeaverTeam.com/

  • Dynamically removing objects

    Hi all,
    I am trying to remove objects at run time using a delete button but I keep getting an error saying
    "no capability to write children". I have set the detach() capability on the Branch Group for adding the object and have set all the relevant capabilities(as far as i can see).
    I can add objects at run time to the scene but cant figure out why I keep getting this error.??
    Any help would be gratefully accepted.
    Cheers,
    Dave

    I'll assume you have something similar to this:
    Group g
    |-----> Other stuff
    \-----> BranchGroup bg
    g must have the capability Group.ALLOW_CHILDREN_WRITE set. bg must have the capability BranchGroup.ALLOW_DETACH set.
    Then, you remove bg like this:
    g.removeChild(bg);

  • Dynamically removing context attribute

    Hi all,
    does anybody know a better way of getting rid of dynamically created attributes than using the IWDContext.reset() functionality?
    Best regards,
    Christian

    Hi,
    We had the similar requirement .We have mailed to Uwe regarding this.Please find the reply below .
    there is currently no way to remove a single attribute in NW04. There is only the possibility to reset the metadata to the state that has been declared in the design time. This can be achieved using IWDContext.reset(boolean), reachable via wdContext.getAPI(). The method removes all attributes and nodes, that have been added at run time ("dynamically"), via one of the add…Attribute or add…Child methods of IWDNode. So, if you have added the root attribute at runtime, this method will remove it, but it removes all other dynamically added attributes and nodes, too.
    NW05 will allow to remove single attributes and child nodes, but still only if they have been dynamically added before.
    Regards
    Anil

  • 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 remove LOV from item

    Hi All,
    i have 2 items, item A and item B. The value of item A determines if a LOV will be created from item B. When i have item A filled with a value so that we need a LOV on item B, i will dynamically build up the record group for this LOV and assign this LOV to item B. But when i then change item A so that no LOV must be used for item B, the previous LOV stays assigned to item B. How can i unassign this LOV from item B? Set_item_property('itemB',lov_name,''); doesn't work.
    Please help.
    Kind regards,
    Dave

    Thanks for the reactions.
    I checked my code again, and it was my fault.
    set_item_property('itemB',lov_name,''); does work, i only put it in the wrong place.
    Kind regards,
    Dave

Maybe you are looking for