Null Object Reference in new Frames

Hello,
I keep on having trouble accessing MovieClips in new frames through actionscript. Lets say for example I have movieclip mc on frame 2 of my fla. Then in actionscript if i do gotoAndStop(2) and then try to access mc I get an Null object reference error. And i understand that it is because the mc has not been created yet even though i told it to go to frame 2. Is there a way to know when the object has been initialized so that I can use it. Or is there a workaround for this problem other than creating the mc in as3 or changing the visibility of the mc?

Thanks.

I think this should work
///////////////////////////////////////

mc.addEventListener(Event.Load,yourfunction);

function yourfunction(){
mc.gotoAndPlay(2);
}

well if my mc is on the second frame, its not going to be instantiated in the previous frames for me to add an event listener

Look into addframescript.

i think that your thinking is bad, do not use frames at all :slight_smile:

[QUOTE=.ral:cr;2354483]i think that your thinking is bad, do not use frames at all :)[/QUOTE]

There are certain animations that are most certainly best done with frames - complex hand-done animations, or another example is embedded FLVs.

There are a number of issues with Flash Player 9 and child access after frame navigation (which I made sure were completely if not mostly resolved for FP10 ;)). Right now, I think the most reliable method, if not using a frame script, is to use the movie clip’s constructor to call a callback or some pre-defined method in its parent (your target timeline) or use the timeline’s Event.ADDED event to detect when it’s been added to the display list. One thing about ADDED is that it will fire for all child movie clips, so you might want to check event.target to make sure you’re getting what you expect, and maybe use a switch statement if you’re performing a number of different actions for different movie clips.

wow thank you for the help. ive had this problem a while and had to do some shady workarounds.

how did yall find out about addFrameScript if its not documented?