A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: removing thats swf that is external thats is inside one single movie clip

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    1

    removing thats swf that is external thats is inside one single movie clip

    i have a university project and instead of just constantly asking for help in my class. I want to gain knowledge outside of the class.

    I have 4 buttons that each load different external swf and load properly the probelm i have is i cant remove them. this is my trouble. I have tried the remove child but it cant be that easy and it doesnt work. i must be going wrong.

    when i go to remove one single child it remove the the latest child but wont remove every child that i want so the MC is clear and ready for the nest button to load the swf.

    heres my code so far.
    Code:
    import flash.events.MouseEvent;
    import flash.media.SoundMixer;
    
    var load1:URLRequest=new URLRequest("bigmp3.swf");
    var load2:URLRequest=new URLRequest("flashgallery.swf");
    var load3:URLRequest=new URLRequest("txt.swf");
    var load4:URLRequest=new URLRequest("s.swf");
    
    var img1loader:Loader = new Loader();
    var img2loader:Loader = new Loader();
    var img3loader:Loader = new Loader();
    var img4loader:Loader = new Loader();
    var mysquare = new square()
    
    
    
    load1_mc.addEventListener(MouseEvent.CLICK, click1);
    load2_mc.addEventListener(MouseEvent.CLICK, click2);
    load3_mc.addEventListener(MouseEvent.CLICK, click3);
    load4_mc.addEventListener(MouseEvent.CLICK, click4);
    
    
    
    
    function click1(event:MouseEvent) {
    	img1loader.load(load1);
    	mcloader.addChild(img1loader)
    	SoundMixer.stopAll();
    	mcloader.unloadAndStop
    }
    
    function click2(event:MouseEvent) {
    	img2loader.load(load2);
    	mcloader.addChild(img2loader)
    	SoundMixer.stopAll();
    	mcloader.unloadAndStop
    	
    }
    
    function click3(event:MouseEvent) {
    	img3loader.load(load3);
    	mcloader.addChild(img3loader)
    	SoundMixer.stopAll()
    	mcloader.unloadAndStop
    	
    
    }
    
    function click4(event:MouseEvent) {
    	img4loader.load(load4);
    	mcloader.addChild(img4loader)
    	SoundMixer.stopAll();
    	mcloader.unloadAndStop
    }
    mcloader.unloadAndStop is obviously worng and i have been through many others code.
    as i have said i can load the swf but then to make that swf gone from the MC so then the next swf hasnt got the previous swf overlapping it.

    thanks
    Last edited by 5TonsOfFlax; 11-18-2011 at 12:50 PM. Reason: code goes in code tags. non-code doesn't.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Do you only want one loaded swf to show at a time? If so, then you do not need to repeat yourself 4 times. Just put a single loader in the mc, and tell it to load the new thing. The new thing will replace the old thing.
    Code:
    import flash.events.MouseEvent;
    import flash.media.SoundMixer;
    
    var load1:URLRequest=new URLRequest("bigmp3.swf");
    var load2:URLRequest=new URLRequest("flashgallery.swf");
    var load3:URLRequest=new URLRequest("txt.swf");
    var load4:URLRequest=new URLRequest("s.swf");
    
    var imgloader:Loader = new Loader();
    mcloader.addChild(imgloader);
    
    load1_mc.addEventListener(MouseEvent.CLICK, click);
    load2_mc.addEventListener(MouseEvent.CLICK, click);
    load3_mc.addEventListener(MouseEvent.CLICK, click);
    load4_mc.addEventListener(MouseEvent.CLICK, click);
    //if those are really MovieClips, you could just assign a property to each dynamically
    //load1_mc.toLoad = load1;
    //etc
    var urlByButton:Dictionary = new Dictionary();
    urlByButton[load1_mc] = load1;
    urlByButton[load2_mc] = load2;
    urlByButton[load3_mc] = load3;
    urlByButton[load4_mc] = load4;
    
    function click(event:MouseEvent):void{
    	SoundMixer.stopAll();
    	imgloader.load(urlByButton[event.currentTarget]);
    }
    Last edited by 5TonsOfFlax; 11-18-2011 at 01:00 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