Skip to main content
January 31, 2011
Question

How to hide or delete movieclip using AS3

  • January 31, 2011
  • 1 reply
  • 4504 views

I have different layers and different movieclip in the stage and when the movieClip is clicked it load the external movieclip.

here is the code

var swfLoader:Loader;

function swfLoaded(evt:Event):void

{

var myStates:MovieClip = (evt.target.content) as MovieClip;

addChild(myStates);

}

function loadLondon(evt:MouseEvent):void

{

swfLoader = new Loader();

swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE ,swfLoaded);

swfLoader.load(new URLRequest("london.swf"));

}

london.addEventListener(MouseEvent.CLICK, loadLondon);

Here external SWF is loaded sucessfully fully but  all the content remain in back.( I mean i can see the london and other behind the new swf);

how to remove those contents(ie. london );

I mean when i load external swf all the elements in current state must me removed and i can only see the new swf in the stage.

Please Help me

This topic has been closed for replies.

1 reply

January 31, 2011

You have two options:

var swfLoader:Loader;

function swfLoaded(evt:Event):void

{

var myStates:MovieClip = (evt.target.content) as MovieClip;

addChild(myStates);

removeChild(london); //  option 1

london.visible=fale; // option 2

}

function loadLondon(evt:MouseEvent):void

{

swfLoader = new Loader();

swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE ,swfLoaded);

swfLoader.load(new URLRequest("london.swf"));

}

london.addEventListener(MouseEvent.CLICK, loadLondon);

February 1, 2011

Thanks for reply but my suitation is i have lot of movie clips like london,scotland,wales etc besides this i have border in seperate layer,gradient in seperate layer , dropshadow in seperate layer.  When any body clicks either london, scotland or any other movie clip then respective map should be loaded and all existing movie clip(london,wales,border etc) should be removed from the stage. How can i do this.

thanks

February 1, 2011

put them all in an array and remove them in a loop.