I am loading an external swf into the main stage. The close button is within the new swf. What I need is when user clicks the close button the animation in the loaded swf plays until the end of the timeline than unloads itself. Below is the code so far but it does not allow the loaded swf to play the animation, it unloads it immediately;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
var project1:URLRequest = new URLRequest(“projects/p1.swf”);
var project2:URLRequest = new URLRequest(“projects/p2.swf”);
var project3:URLRequest = new URLRequest(“projects/p3.swf”);
p1.addEventListener (‘mouseDown’, function() {
loader.load(project1);
});
p2.addEventListener (‘mouseDown’, function() {
loader.load(project2);
});
p3.addEventListener (‘mouseDown’, function() {
loader.load(project3);
});
function loadComplete(event:Event):void {
addChild(loader);
MovieClip(loader.content).mycursor.addEventListener(MouseEvent.CLICK, unloader);
}
function unloader(event:MouseEvent):void {
removeChild(loader);
loader.unload();
loader = null;
}