...

View Full Version : Unloading SWF from movieclip



senkei
06-02-2009, 06:12 PM
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.



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.

senkei
06-02-2009, 11:27 PM
[Problem Solved]

See: http://board.flashkit.com/board/showthread.php?t=796261



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum