Jump to content
GreenSock

digisam

Members
  • Posts

    3
  • Joined

  • Last visited

Reputation

0 Newbie
  1. Hi I am attempting to load a large relatively complicated swf (300mb) into a parent swf to then be given to the client as an exe. It is for a touchscreen application. It was all working fine then after a few hours of use there were crashes. I tried to track down any memory leaks, all event listeners were set to weak and I am using gSkinners Janitor class to watch and remove any listeners. I was testing in the debug version, which I have since learned does not give good reports of memory usage and doesn't show any GC. This was a major blow as I had spent a week basing all my tweaks on these results, but when i tried in the regular player the memory (as monitored with SWFProfiler) was being managed well (it was going down rather than constantly up) So I am now using LoaderMax to load and unload the swf to just make sure that there are no leaks by completely removing the swf and reloading it. I know this is not the best way to do things but given this whole AS3 project has been a transition from AS2 I have not approached it in an OOP fashion. Instead went for the old school AS2 all code on the first frame with a variety of includes. The problem I am having is when i start to stress test. I have set up a mouse macro that performs the same actions over and over to simulate multiple users and pauses. There is a timeout in the child swf that checks for mouse movement, if there is none it starts a countdown and then sends a call to the parent to unload and reload after performing the Janitor/Destroy tasks. This works fine, the child swf is being marked for garbage collection and eventually gets removed and a new one reloaded. But after a period of time, sometimes 10 minutes, sometimes 45 there will come a point when the child swf will not load again and the user is left with a black screen. I am also unable to manually trigger function with a keyboard press (for dev purposes, the terminals do not have keyboards) I am not getting an error message from the error handler, it is like it is not being triggered at all. My error txt on stage (as i have to test in a exe on a pc) ends on loadIWM. And when i manually trigger "unloadSWF" it runs up until that point. Is there a way to check that the loader still exists, if not to create another one on the stage? I think what is happening is the computer has a bit of a disk fart sometimes and interrupts the load causing it to fail. I have just done a test where i manual led called unloadSWF 20 times and it worked. I hate bugs like this. Fingers crossed. stage.addEventListener(KeyboardEvent.KEY_UP, displayKey, false, 0, true); var mcExternal:MovieClip; function displayKey(keyEvent:KeyboardEvent) { var keyPressed:String = ""; keyPressed = keyEvent.keyCode.toString(); trace(keyPressed); if (keyPressed=="186") {//; unloadSwf(); //System.gc(); } } var loader:SWFLoader = new SWFLoader("assets/allpress_main_fs.swf", { onComplete:swfIn, onError:errorHandler, onProgress:progressHandler}); addChild(loader.content); function loadIWM() { //add the ContentDisplay to the display list even before raw content is loaded. loader.load(true); trace("loadIWM"); error_mc.textBox.text = "loadIWM"; clearInterval(myInterval); addChild(error_mc); } function errorHandler(event:LoaderEvent):void { trace("error occured with " + event.target + ": " + event.text); trace("LOADERERROR"); error_mc.textBox.text = "LOADERERROR" + event.target + ": " + event.text; } function progressHandler(event:LoaderEvent):void { //trace("progress: " + event.target.progress); //error_mc.textBox.text = "progress: " + event.target.progress; } var error_mc:MovieClip = new errorText(); error_mc.textBox.text = "started"; function swfIn(e:Event):void { error_mc.textBox.text = "swfIn"; mcExternal = loader.rawContent; } var myInterval:uint; loaderJanitor.addIntervalID(myInterval); function unloadSwf() { trace("unloadSwf") error_mc.textBox.text = "unloadSwf"; loaderBG.alpha = 0; mcExternal=null; timedLaunch(); } function hiDad() { trace("hi dad"); } function timedLaunch() { trace("timedLaunch") error_mc.textBox.text = "timedLaunch"; myInterval = setInterval(loadIWM, 1000); } fadeBG(); loadIWM();
  2. Thank you. That worked a treat. Yes it is struggle grasping the concepts of AS3. I do find it hard to let go of naming everything, but then if i don't name them I lose track of items very quickly. I think I will continue with naming them in this first transition, with what I know now compared to when I started I would have approached the projects very differently. Again, thank you very much. Sam
  3. Hi, first time posting after too many hours trying to find out what I am doing wrong. I have an XMLlist that loops through my XML fine and loads the images and places them where I want them. But I can not figure out how to add an event listener to the images that are loaded, the contentDisplay. I can see in my displayList that the bitmaps are loaded into the contentDisplay and are given the names thumbnail0, thumbnail1 etc instance23 [object MovieClip] instance24 [object Sprite] thumbnail0 [object ContentDisplay] [object Bitmap] instance28 [object icon_zoom] [object Shape] thumbnail1 [object ContentDisplay] [object Bitmap] instance33 [object icon_zoom] [object Shape] When i try to add an event listener I always get errors. The eventListener is added to the galleryIcons that are pulled from the library fine. I try: this["thumbnail" + i].addEventListener(MouseEvent.CLICK, openLightBox); or ["thumbnail" + i].addEventListener(MouseEvent.CLICK, openLightBox); or thumbNailLoader.addEventListener(MouseEvent.CLICK, openLightBox); After searching other forums suggested the first two would be the correct way of constructing the addListener, but there give me "1064 Invalid metadata" It might be a way i am constructing my code, this is my first project in AS3 after many years working with AS2. I am forcing myself through the horrendous learning curve because I felt it is about time. And who knew how slack AS2 was at accepting errors, but as we know AS3 has none of it. Typically I can find an answer to my problems but their has me stumped, and i am really hoping it is going to be a face palm moment when i find out. Is it something to do with me trying to add the listener before the image has loaded? When i try it in the imageLoaded function I get the same error. Any help would be appreciated. Many thanks var i:int = 0; for each (var puImage:XML in puImageList) { trace("thumbNail", puImage.@thumbnail); var puThumbNailToLoad:String = puImage.@thumbnail; var puThumbNailW:Number = puImage.@tnWidth; var puThumbNailH:Number = puImage.@tnHeight; var puThumbNailX:Number = puImage.@tnX; var puThumbNailY:Number = puImage.@tnY; trace("puThumbNailToLoad", ["thumbnail"+i]) var thumbNailLoader:ImageLoader = new ImageLoader(puThumbNailToLoad, {name:"thumbnail"+i, x:puThumbNailX, y:puThumbNailY, container:puImagesHolder, smoothing:true, onComplete:imageLoaded}); thumbNailLoader.load(); //["thumbnail"+i]addEventListener(MouseEvent.CLICK, openLightBox); //ADD ICON BASED ON THE POSITIONS OF THE IMAGE JUST LOADED var galleryIcon:MovieClip = new icon_zoom() as MovieClip; //POSITION ICONS puImagesHolder.addChild(galleryIcon) galleryIcon.x = puThumbNailW; galleryIcon.y = puThumbNailY-13; galleryIcon.addEventListener(MouseEvent.CLICK, openLightBox); function imageLoaded(e:Event) { this["thumbnail" + i].addEventListener(MouseEvent.CLICK, openLightBox); } i++; }
×