views:

1116

answers:

3

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/

A: 

I've generally found that when you have objects on the timeline, in order to access them with actionscript, they have to be on all the frames of the timeline, you'll just have set their visibility to hidden when they're not supposed to be on screen. I'm pretty sure I've run into this problem with fp10 as well as fp9, so I'm surprised your code actually works for you in fp10.

quoo
+2  A: 

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.

grapefrukt
Wow, after some googling (I know, I know I should have started there) I found where this was quite the issue - it's addressed here with a ton of links on the issue - thanks for the answer! http://bugs.adobe.com/jira/browse/FP-43
onekidney
A: 

actually works for you in fp10. but not for AIR1.1

peam