0
votes

I have a Android Air application, where I import a png image to the stage on frame two and converted it to a symbol as a movieclip. I am performing a hovering animation using this image as a movieclip and it works great but when I go from frame 2, where the animation is, and I move to frame 3, 4, 5, or 6, and then I move back to frame 2, my application throws a errors when referencing the movieclip again. The error is 1009 cannot access null object reference. So to me it seems that once the timeline moves away from frame 2 it wipes away the reference to the imported image converted to a movieclip....is this correct? Is there a way I can keep the timeline referencing the this image as a movieclip so I can always come back to this frame?

thanks Scientific

1
do you use keyframes? if yes, have you given your MCs a name (the same) on all keyframes? - Philipp Kyeck
whene switching between keyframes all loaded data are wiped - mgraph
Yes I am using keyframes. Ok this makes sense. Should I load the picture onto the stage and then convert it to a movieclip using code? - AgnosticDev
You can import your picture into your library converted there to a symbol and add it dynamically to your stage through code,when you instantiate the class with the picture,reference the object to a variable so you don't lose the pointer.If you have issues of losing data every time you switch to frames use a main document class file to place all your code. - giannis christofakis
That is a great idea. So when I import the object to the stage I would just create a class with te same name and do my manipulation from there ? - AgnosticDev

1 Answers

1
votes

You can listen for the EXIT_FRAME event every time you stop at the frame containing the movie clip:

function miClick(e:MouseEvent) { 
    content.gotoAndStop(e.currentTarget.parent.name); 

    if(e.currentTarget.parent.name == "2") { 
        content.addEventListener(Event.EXIT_FRAME, this.hdExitFrame); 
        productMenu.alpha = 1; 
        trace(content.products); 
    } else { 
        productMenu.alpha = 0; 
    } 
} 

function hdExitFrame(e:Event) { 
    trace(e.target.currentFrame + ", " + e.target.products); 
    content.removeEventListener(Event.EXIT_FRAME, this.hdExitFrame); 
} 

in this paricular code snip, content.products is usually null at first, but in hdExitFrame, it's not.