Jump to content
Search Community

Loading Multiple swfs

darloScott test
Moderator Tag

Recommended Posts

Hi,

 

I'm having issues with createing multiple SWFLoaders inside LoaderMax, I can load two SWFLoaders into LoaderMax fine in the same method like this:

 

_appDomain = new ApplicationDomain();         
_loader = new LoaderMax({ name:"themeLoader", onComplete:completeHandler, autoDispose:true});
_loader.append(new SWFLoader("Views.swf", {name:"interfacePackage",
context:new LoaderContext(false, _appDomain),
autoDispose:true, autoPlay:false}));
_loader.load();						

trace("load second theme");
_loader.append(new SWFLoader("ViewsTwo.swf", {name:"interfacePackageTwo",
context:new LoaderContext(false, _appDomain),
onComplete:getContentSecond,
autoDispose:true, autoPlay:false}));
_loader.load();

 

BUT as soon as I want to load the second SWF on a MouseEvent it doesn't load. The code is below:

 

private function loadAssets():void{

_appDomain = new ApplicationDomain();         
_loader = new LoaderMax({ name:"themeLoader", onComplete:completeHandler, autoDispose:true});
_loader.append(new SWFLoader("Views.swf", {name:"interfacePackage",
context:new LoaderContext(false, _appDomain),
autoDispose:true, autoPlay:false}));
_loader.load();			

var btn:MovieClip =  new MovieClip();
btn.graphics.beginFill(0xff9900);
btn.graphics.drawRect(0,0,100,100);
btn.graphics.endFill();
addChild(btn);
btn.addEventListener(MouseEvent.CLICK,loadSecondTheme);			
}

private function loadSecondTheme(e:MouseEvent):void{
trace("load second theme");
_loader.append(new SWFLoader("ViewsTwo.swf", {name:"interfacePackageTwo",
context:new LoaderContext(false, _appDomain),
onComplete:getContentSecond,
autoDispose:true, autoPlay:false}));
_loader.load();				
}

 

Has anyone had the same problem? Any help would be appreciated. I have attached the simple test files I have created, hopefully there is a simple solution.

 

Thanks,

 

Scott

Link to comment
Share on other sites

Looks like the problem is that you set autoDispose:true on your LoaderMax and then after it's loaded (and consequently disposed), you try appending more loaders to it and loading it. You need to decide if you want it disposed or not - if a loader is disposed, it is cleaned internally and made ready for garbage collection, so you shouldn't reuse it after that point. Just set autoDispose to false (or don't set it at all - false is the default) and you'll be fine.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...