Skip navigation
Currently Being Moderated

Array values missing

Apr 5, 2012 4:46 PM

I have an odd problem, odd to me anyway. It seems some of the values in my array go missing.  I load in some swfs, capture some screenshots from them as Bitmaps, and place all those bitmaps in an array.  I access that array and display the contents on screen as part of my application loading, When I try to access that array later via a mouse over, most of bitmaps in the array are gone, but some remain (generally the last few).

I am placing the array in a robotlegs singleton as I need them periodically throughout my application.  I am thinking this has something to do with memory issue or garbage collection, but not sure, any advice would be great,


  • kglad
    72,227 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 5, 2012 5:36 PM   in reply to 5Systems

    as long as your array references still exist, nothing they point to (your bitmaps) will be gc'd.


    use the trace() function to debug your problem.  exactly how to do that depends on your coding.

    Mark as:
  • Currently Being Moderated
    Apr 6, 2012 10:55 AM   in reply to 5Systems

    Where is contentModel coming from that you use the contentModel.clipWidth and contentModel.clipHeight?


    You really should put a trace() in that function as mentioned, or a breakpoint and run it in debug, so you can watch every time that _screenshotArray is accessed and what the contents of it is.


    Otherwise I see no problem with your logic as long as the last frame (clip.totalFrames) contains the screenshot you really want and no code up till that point was necessary to create the graphics at that point in time because you're skipping right to the end.

    Mark as:
  • kglad
    72,227 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 6, 2012 12:31 PM   in reply to 5Systems

    i do see a problem with that goto.  i'm not sure that's the cause of the problem you're reporting but when you execute a goto, the player doesn't advance the frame and render the new frame's contents immediately.


    use the render event after invalidating your stage to ensure you're making a bitmap of the last frame's contents:




    private function createScreenShots(loadedSwf:SWFLoader):void



            var clip:MovieClip = loadedSwf.content as MovieClip;





    } else {

    trace("fix this so you have a reference to a display list object")





    private function renderF(e:Event):void{

    trace(contentModel.clipWidth,contentModel.clipHeight);  // make sure this not 0,0

            var rawScreenData:BitmapData = new BitmapData(contentModel.clipWidth, contentModel.clipHeight, true, 0x000000);



           var screenShot:Bitmap = new Bitmap(rawScreenData, "auto", true);




           //dispatch event that will carry a copy of as single screenshot as a payload

           dispatch(new ScreenShotEvent(ScreenShotEvent.SEND_SCREENSHOT, screenShot));


    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points