Share Posted September 22, 2010 Hi I am having truble integrating child swf loaders in to main swf loading. I read docs and it should work by default but i can no get it to work. My parent swf fires its complete event before child swf finishes with its loads. My setup is as like this: index.swf that contains following code: pageLoaderMax = new LoaderMax({name: "pageLoaderMax", onComplete: pageLoaded, requireWithRoot:this.root}); pageLoaderMax.append( new SWFLoader("page.swf", {name:"pageLoader", container: pageHolder, requireWithRoot:this.root }) ); pageLoaderMax.load(); } ////preloaderLoaded function pageLoaded(evt:LoaderEvent):void { trace("PAGE LOADED"); } This swf is only responsible for loading page swf that contains multiple SWF loaders inside one LoderMax, like this: mainPartsLoader = new LoaderMax({name:"mainPartsLoader", onComplete: mainPartsLoaded, onProgress: progressHandler, requireWithRoot:this.root}); mainPartsLoader.append( new SWFLoader("swfs/background.swf", {name: "bg", container: bgHolder, y: 0, requireWithRoot:this.root}) ); mainPartsLoader.append( new SWFLoader("swfs/blueBar.swf", {name: "blueBar", container: blueBarHolder, y: 630, requireWithRoot:this.root}) ); mainPartsLoader.append( new SWFLoader("swfs/btnPortfolio.swf", {name: "btnPortfolio", container: buttonsMainHolder, requireWithRoot:this.root, x: 328, onComplete: btnLoaded}) ); mainPartsLoader.append( new SWFLoader("swfs/btnFoto.swf", {name: "btnFoto", container: buttonsMainHolder, requireWithRoot:this.root, x: 439, onComplete: btnLoaded}) ); mainPartsLoader.append( new SWFLoader("swfs/btnInfo.swf", {name: "btnInfo", container: buttonsMainHolder, requireWithRoot:this.root, x: 550, onComplete: btnLoaded}) ); mainPartsLoader.append( new SWFLoader("swfs/btnArhiv.swf", {name: "btnArhiv", container: buttonsMainHolder, requireWithRoot:this.root, x: 662, onComplete: btnLoaded}) ); mainPartsLoader.append( new SWFLoader("swfs/btnReel.swf", {name: "btnReel", container: buttonsMainHolder, requireWithRoot:this.root, x: 773, onComplete: btnLoaded}) ); mainPartsLoader.load(); function mainPartsLoaded(evt:LoaderEvent):void { trace("all content loaded"); } function progressHandler(event:LoaderEvent):void { // trace("progress: " + event.target.progress * 100); } function btnLoaded(evt:LoaderEvent):void { trace(evt.target.name); //trace("btnLoaded"); } But it does not work and parent swf (index ) gives me eventComplete before child swf finishes and i get traces for actual swfs inside child(page) after i get trace that index.swf (my parent swf) has event.complete. I hope that my explanation makes some sense. So what am i doing wrong. Why do i not get event.complete from parent last? Luka Link to comment Share on other sites More sharing options...
Share Posted September 23, 2010 Does your "this.root" actually return a valid reference or is it null? If your "this" object isn't in the display list, then its root will be null which of course would prevent LoaderMax from associating it properly. Could you please post parent and child FLAs that I can publish and see the problem for myself? The simpler the better - only use the essential code to reproduce the issue. I'm sure we can get it figured out. Link to comment Share on other sites More sharing options...
Author Share Posted September 23, 2010 Hi That would be really great. I have attached both. So far i made workaround with custom event that is dispatched but it would be better to use MaxLoader class events. tnx for your help Luka Link to comment Share on other sites More sharing options...
Share Posted September 23, 2010 I got a bunch of errors when I tried to publish the files (missing google class, missing swfs, etc.) but I think I see exactly what's causing the problem you originally asked about. You're not creating your loaders on the first frame - you create an ENTER_FRAME listener and delay creating the loaders until the next frame render. Therefore when your swf inits, the loaders don't exist and SWFLoader cannot find them. Your loaders MUST exist when your swf inits (finishes rendering its first frame), otherwise LoaderMax can't find them (it would be impossible). See what I mean? Link to comment Share on other sites More sharing options...
Author Share Posted September 23, 2010 Hi I understand what you mean. I will try and will let you know. tnx Luka Link to comment Share on other sites More sharing options...
Author Share Posted September 24, 2010 I got a bunch of errors when I tried to publish the files (missing google class, missing swfs, etc.) but I think I see exactly what's causing the problem you originally asked about. You're not creating your loaders on the first frame - you create an ENTER_FRAME listener and delay creating the loaders until the next frame render. Therefore when your swf inits, the loaders don't exist and SWFLoader cannot find them. Your loaders MUST exist when your swf inits (finishes rendering its first frame), otherwise LoaderMax can't find them (it would be impossible). See what I mean? Tnx a lot for clearing this for me. It is what you said.I made one loader swf that loads other swfs and preloader swf that loads loader swf and it works like docs say it will. I trace preloader complete event after all subload traces. I just did not use ENTER_FRAME event to start the hole thing in the first place. Just for the fun of it i tried again with ENTER_FRAME and it did not work so that was my problem. tnx a lot. this class rocks. Luka Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now