Hello,
I just started working with loading external SWF’s into a different SWF. Right now I have a swf called Hacker (text based mostly , using Main.as as its class), and another swf called GTC 1.1 . In Hacker I have a movie clip named loadMiniGameMC , within that movieClip is this code on frame 1 of the timeline:
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
var mLoader:Loader = new Loader();
var mRequest:URLRequest
function startLoad()
{
mRequest = new URLRequest("GTC 1.1.swf");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
}
function onCompleteHandler(loadEvent:Event)
{
addChild(loadEvent.currentTarget.content);
mLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgressHandler);
}
function onProgressHandler(mProgress:ProgressEvent)
{
var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
trace(percent);
}
function unLoad()
{
mLoader.unloadAndStop();
}
within Main.as (controlling Hacker) I have this code snippet:
case "reconnect 187.65.0.1":
if(levelProgression [3] == 6)
{
miniGameOne.visible = true;
miniGameOne.startLoad();
}
break;
case "try again 187.65.0.1":
if(budget >= 75)
{
miniGameOne.visible = false;
miniGameOne.unLoad();
budget -= 75;
}
Now how the run of it goes is player is playing Hacker, gets to a part where GTC 1.1 loads, everything is fine, it works perfect yadda yadda, then player types in keyword (in this case try again 187.65.0.1) and it toggles the visibility of the miniGameOne (which is on the stage, a child of miniGameOneMC) and calls it’s unLoad function.
Now the players have the choice of doing that same level again (GTC 1.1), but when I call the function for it to load, it loads ANOTHER copy of GTC ontop of the old you (you can still see some of the changes made by the player on the previous GTC)…the new copy works just as well, except for the graphic leak and most likely the memory leak.
I have also tried adding an unload listener inside of miniGameOneMC AND miniGameOne which would delete ALL of the event listeners on unload, but then it wouldn’t even work at all, couldn’t click anything ect., I also tried loading something else into the loader inbetween, manually calling a function within miniGameOne which would unload, then reload a different swf called “gimick”, and then when the players tried to reload the game again (for their 2nd time) unload gimick and reload miniGameOne, every time I still get two copies of the SWF layered ontop of each other
I’ve searched for a long time for a way to iron this out and haven’t found any yet, so any help would be GREATLY appreciated