Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    29
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Unloading SWF from movieclip

    Hi guys, i need help with this code that concerns unloading a SWF from a movie clip. This code is inside a movie clip acting as a button that loads the SWF into another movie clip in the main timeline called "rootbox_mc". Basically when i spam the button, it keeps loading the external SWF over and over the one already loaded, i want it to remove the one already loaded before loading another in its place.

    More specifically, i wanted to ask why my if statements were not working, and how do you actually unload a loaded external SWF. I read that you just delete the child, and that's what i tried to do here.

    Code:
    this.addEventListener(MouseEvent.CLICK, load1Release);
    	function load1Release(evt:MouseEvent):void {
    
    		var checker:Number=0;
    		var myLoader1:Loader = new Loader();
    		
    		if(checker==1) {
    			removeChild(myLoader1);
    			//myLoader1.unload;
    			addChild(myLoader1);
    		} else {
    			addChild(myLoader1);
    			var myRequest1:URLRequest = new URLRequest("maya_import.swf");
    			myLoader1.load(myRequest1);
    			
    			// ---------- progress tracking AS ----------
    			
    			myLoader1.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader1);
    			myLoader1.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress1);
    			myLoader1.contentLoaderInfo.addEventListener(Event.COMPLETE,showLoadResult1);
    			
    			function showPreloader1(evt:Event):void {} 
    			
    			function showProgress1(evt:ProgressEvent):void { 
    				var loadProgress_percent = evt.bytesLoaded / evt.bytesTotal; trace("loadProgress_percent: " + loadProgress_percent*100);
    			} 
    			
    			function showLoadResult1(evt:Event):void {
    				MovieClip(parent).rootbox_mc.addChild(myLoader1.content);
    				checker=1;
    				trace(checker)
    				//trace("GOT showLoadResult");
    				//trace("maya_import LOADED!");
    				//rootbox_mc.stop();
    			}
    		}
    	};
    Thanks!

    ps; This code is someone else's code that i found on the internet. I tried to modify it to fit what i'm trying to do, but it is currently not working. I am a total flash newb so i don't understand all of it.

  • #2
    New Coder
    Join Date
    Jul 2007
    Posts
    29
    Thanks
    6
    Thanked 0 Times in 0 Posts


  •  

    Posting Permissions

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