Jump to content
Search Community

aaseb

Members
  • Posts

    19
  • Joined

  • Last visited

aaseb's Achievements

0

Reputation

  1. Wow! you did it again.I'ts nice to see my request wasn't stupid and impossible and also that in a way it brought an improvement to loadermax. Thanks a lot Greensock
  2. YES! In the example without loadermax the memory load goes up when the child swf is loaded and down every time the child swf is unloaded (no cleanup code needed). In the example with loadermax, the memory load keeps going up and never comes down. Even after calling "l.dispose(true);" The trace still returns l.content is [object ContentDisplay]. I know I'm trying to do things the wrong way and proper cleanup is the right way but the way I see it is if it works without loadermax, why can't it work with loadermax.
  3. This is what I come with when I adapt this code for loadermax : import flash.display.Loader; import flash.utils.Timer; import flash.events.TimerEvent; import flash.system.ApplicationDomain; import flash.system.LoaderContext; import flash.system.System; import flash.net.LocalConnection; import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import com.greensock.loading.display.*; var t : Timer = new Timer(2000); //var l : Loader = new Loader(); //this was changed to this : var l:SWFLoader = new SWFLoader("child1.swf", {name:"childClip1", context:lc}); /* use a loadercontext with a new applicationdomain() */ var lc : LoaderContext = new LoaderContext(); lc.applicationDomain = new ApplicationDomain(); t.addEventListener(TimerEvent.TIMER, fOnTimer); t.start(); //addChild(l); //this was changed to this : l.load(); addChild(l.content); function fOnTimer(e : TimerEvent) : void { if (l.content != null) { //l.unloadAndStop(); //this was changed to this : l.unload(); //removeChild(l); //this was changed to this : removeChild(l.content); trace("l.content is " + l.content) l = null; //l = new Loader(); //this was changed to this : l = new SWFLoader("child1.swf", {name:"childClip1", context:lc}); //addChild(l); //this was removed lc = null; trace(System.totalMemory) System.gc(); System.gc(); try { new LocalConnection().connect('gc'); new LocalConnection().connect('gc'); } catch (e:*) {} } else //l.load(new URLRequest("child1.swf"), lc); //this was changed to this : l = new SWFLoader("child1.swf", {name:"childClip1", context:lc}); l.load(); addChild(l.content); } notice the "trace("l.content is " + l.content)" I added, in this code it returns "l.content is [object ContentDisplay]" as when I test the same thing in the previous code without loadermax, I get "l.content is null". I think this might be why it's not working. Any ideas on how to make the swfloader content null?
  4. This is the way I had solved this problem without doing any cleanup and before using loadermax. Thanks to this link : http://simplistika.com/as3-garbage-collection-solved/ Now the code and sample file they give works fine since it's only an image being loaded. To make it work with a sloppy swf with no cleanup inside I had to add just a few things. Here is the modified code : import flash.display.Loader; import flash.utils.Timer; import flash.events.TimerEvent; import flash.system.ApplicationDomain; import flash.system.LoaderContext; import flash.system.System; import flash.net.LocalConnection; var t : Timer = new Timer(2000); var l : Loader = new Loader(); /* use a loadercontext with a new applicationdomain() */ var lc : LoaderContext = new LoaderContext(); lc.applicationDomain = new ApplicationDomain(); t.addEventListener(TimerEvent.TIMER, fOnTimer); t.start(); addChild(l); function fOnTimer(e : TimerEvent) : void { if (l.content != null) { l.unloadAndStop(); //this is what i added removeChild(l); l = null; l = new Loader(); addChild(l); lc = null; trace(System.totalMemory) //end of what i added System.gc(); System.gc(); try { new LocalConnection().connect('gc'); new LocalConnection().connect('gc'); } catch (e:*) {} } else l.load(new URLRequest("child1.swf"), lc); } Now this is surely not best practice and it's probably better to do the cleaning yourself but it saves a lot of time and it works. I tried to adapt this code for loadermax but I must be doing it wrong. Could it work with loadermax too?
  5. IT WORKS! I only had to change "addedToStageListener" to "addedToStageHandler" and "function dispose():void {" to "function dispose(event:Event):void {" you're the man greensock. I still think if there was a way to avoid having to put this cleanup code it would make life more simple. Is there a list somewhere of things that need to be cleaned up and things that don't.
  6. I wish it was that simple. Did you check my post? "unload and cleanup" Not exactly the same but close enough the goal is to load and use several swf without causing memory issues.
  7. I tried that, it seems the stage is null so the cleanup is not happening. if i put this before the cleanup code : trace("stage :" + stage); i get : stage :[object Stage] but if i put it inside the cleanup code i get stage : null.
  8. I only wish I knew what that means. If I remove the eventlistener with the help of a button bufore unloading it works fine.
  9. ok the function is called when i leave the code as it is now I add my cleanup code like this : function dispose(event:Event):void { //do cleanup stuff here like removing event listeners, stopping sounds, closing NetStreams, etc... stage.removeEventListener(Event.RESIZE, stagefunction); trace("cleanup done"); } and i get this : TypeError: Error #1009: Cannot access a property or method of a null object reference. at child1_fla::MainTimeline/dispose() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at com.greensock.loading.core::LoaderCore/_dump() at com.greensock.loading.core::LoaderItem/_dump() at com.greensock.loading.core::DisplayObjectLoader/_dump() at com.greensock.loading::SWFLoader/_dump() at com.greensock.loading.core::LoaderCore/unload() at test_fla::MainTimeline/frame61() at flash.display::MovieClip/gotoAndPlay() at test_fla::MainTimeline/gotounload()
  10. still doing some more testing to see exactly what causes the problem and how to fix it. having event listeners on buttons in the loaded swf will not cause the problem, having variables in the loaded swf will not cause the problem having event listeners on the stage in the loaded swf WILL cause the problem. There's probably other things that cause the problem but maybe not so many so adding cleanup code on unload is probably the best solution. Now I'm trying to figure out how to do that. i copied this code from another post: var curParent:DisplayObjectContainer = this.parent; while (curParent) { if (curParent.hasOwnProperty("loader") && curParent.hasOwnProperty("rawContent")) { Object(curParent).loader.addEventListener("unload", dispose, false, 0, true); } curParent = curParent.parent; } function dispose(event:Event):void { //do cleanup stuff here like removing event listeners, stopping sounds, closing NetStreams, etc... } i just changed "loader" to correspond to the appropriate SWFloader but it seems like the function is not being called on unload.
  11. Hello, I'm trying to load and unload several swf files using loadermax. The problem I run into is that when I unload a swf, it stays in the system memory. After a lot of testing I got it working loading a simple swf with no event listeners inside. When I load a more complex swf with a lot of code inside and event listeners, that's when the system memory keeps going up. So like greensock suggested in an earlier post the problem is coming from cleanup code missing. The thing is that cleanup code is really a lot of work. I ran into this same problem without using loadermax and managed to go around it using application domain than had to set the domain and loader to null so I think it should be possible to go around this problem using loadermax too. Any clues?
  12. I'm confused. I think I'll start a new topic when I find where the problem is really coming from (if I cant find the solution on my own) One thing I noticed though if on the first frame of the loaded SWFs there is a movieclip with a trace inside. The trace will come when you load the queue and before any of the SWFs have been added to the stage, and that even with the autoplay property set to false. Is there any way to tell flash to load those SWFs in the cache only and not start reading anything from them?
  13. It is now working with unload but i still have memory usage issues. I tried using application domain but no luck. I now have this : var _newDomain1:ApplicationDomain = new ApplicationDomain(); var _appContext1:LoaderContext = new LoaderContext(false, _newDomain1); var _newDomain2:ApplicationDomain = new ApplicationDomain(); var _appContext2:LoaderContext = new LoaderContext(false, _newDomain2); var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); var child1:SWFLoader = new SWFLoader("child1.swf", {name:"childClip1", estimatedBytes:3000000, autoPlay:false, context:_appContext1}); var child2:SWFLoader = new SWFLoader("child2.swf", {name:"childClip2", estimatedBytes:3000000, autoPlay:false, context:_appContext2}); after child1 has been loaded i call this to load child 2 LoaderMax.getLoader("childClip1").unload(); child1=null; _appContext1=null; _newDomain1 = null; _newDomain1 = new ApplicationDomain(); _appContext1 = new LoaderContext(false, _newDomain1); child1 = new SWFLoader("child1.swf", {name:"childClip1", estimatedBytes:3000000, autoPlay:false, context:_appContext1}); mycontainer.addChild(child2.content); and do the opposite to go back to child1 but switching from one to the other keeps increasing the memory load. Maybe this should be the start of a new topic... I ran into this same problem without using loadermax and I think using application domain was part of the solution. unloadAndStop() was another part but I think that doesn't work with loadermax. Just to test, I added a loop with a trace in the movie that is loaded and the trace keeps coming even after unloading it.
  14. if i could get a little bit more help?... I now load several swf files like so : var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); var child1:SWFLoader = new SWFLoader("child1.swf", {name:"childClip1", estimatedBytes:3000000, autoPlay:false}); var child2:SWFLoader = new SWFLoader("child2.swf", {name:"childClip2", estimatedBytes:3000000, autoPlay:false}); var child3:SWFLoader = new SWFLoader("child3.swf", {name:"childClip3", estimatedBytes:3000000, autoPlay:false}); var child4:SWFLoader = new SWFLoader("child4.swf", {name:"childClip4", estimatedBytes:3000000, autoPlay:false}); var child5:SWFLoader = new SWFLoader("child5.swf", {name:"childClip5", estimatedBytes:3000000, autoPlay:false}); //append several loaders queue.append(child1); queue.append(child2); queue.append(child3); queue.append(child4); queue.append(child5); queue.load(); when i want one of the swf to show, i load it like this (after i checked to see if it was fully downloaded): mycontainer.addChild(child1.content); LoaderMax.getContent("childClip1").rawContent.gotoAndPlay(1); up to here everything works fine but i can't seem to find the right code to unload this swf and switch to a different one. I'd like the file to remain in the cache but to free system memory when removed. I tried LoaderMax.getContent("childClip1").unload(); but when i load the swf again it doesn't play. I can see it's there because if i right click and say play then i can see it playing.
  15. very nice. Thank you so much for your work.
×
×
  • Create New...