R – In Flash: gotoAndStop and nested MovieClip issues

actionscript-3flash

This is kind of an odd question, I hope this enough information to go on:

In the flash IDE, I have a MovieClip that has 3 frames. In each frame, I have a series of TextFields. It's a poor mans viewstack basically – so here's the issue – in FP10 I can write the following code with no problem:

public function showMenu():void{

     gotoAndStop(2);
     textItem.text = "This worked."

}

where "this" is a MovieClip and textItem is a TextField that is only on the second frame of the movieClip. If I target FP9 and run the same code, I get a 1009 Error about trying to reference a property on an object that is null.

I understand that it is trying to access that property before it was completely instantiated, what I don't understand is why it works in FP10 and not FP9? What could have changed in the flash player to allow this?

UPDATE:

Looks like some weirdness in FP9 – a workaround can be found here:

http://www.scottgmorgan.com/blog/index.php/2008/03/06/accessing-displayobjects-on-the-timeline-after-a-gotoandstop-or-gotoandplay/

Best Answer

Yes, it has changed. This was possible in as2 but disappeared in as3, taking much of the simplicity of shorter timeline scripts with it. So, it was reinstated in FP10. I've read a blog post by someone at adobe about this, but i can't find it right now.

Related Topic