A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: remove internal clip

  1. #1
    Junior Member
    Join Date
    Mar 2008
    Posts
    20

    remove internal clip

    Hi to all.
    I hava a movieclip with a button an this as3:

    Code:
    catalogo.addEventListener(MouseEvent.CLICK, click);
    
    function click(event:MouseEvent):void
    {
    	this.galleria.gotoAndPlay(2);
    }
    So when clicked it goes in galleria movie clip on the 2 frame.

    Now i need a button in galleria that could remove galleria clip when pressed.
    I have tried whit visibility or removechild but nothing worked...

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    What did you try and how didn't it work? Did you get errors? What were they?

    Generally, you do not want a child clip to control the parent. Although you can use the parent or root properties to go up the display hierarchy and then cast to MovieClip and call a method, it's cleaner to dispatch an event from the child and listen for it in the parent/ancestor.

    So if I understand you correctly, this code would go in galleria:
    Code:
    someCloseButton.addEventListener(MouseEvent.CLICK, closeButtonClicked);
    function closeButtonClicked(e:Event):void{
      dispatchEvent(new Event("closeGalleria", true));
    }
    And in galleria's parent:
    Code:
    addEventListener("closeGalleria", closeGalleria);
    function closeGalleria(e:Event):void{
      removeChild(galleria);
      //or:
      //removeChild(e.target);
      //or:
      //removeChild(getChildByName("galleria"));
    }

  3. #3
    Junior Member
    Join Date
    Mar 2008
    Posts
    20
    yes thnx man!!! it works!

    now i would like to add a fadein effect and a fadeout of galleria. for the fade in i did as a tween in galleria mc from frame 2 to frame 20, but how can i do for fadeout when closebutton is clicked?

    Edit: did it simply by creating a fadeout twin and adding at the last frame: dispatchEvent(new Event("closeGalleria", true));
    an action gotoAndPlay at the closebutton.
    Thnx again for help!
    Last edited by havana7; 07-19-2010 at 06:41 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center