PDA

View Full Version : Cant target instances on frames other than 1 from doc class...


Blkhwks19
12-18-2008, 11:26 PM
I'm setting up a registration form. It's all contained in a movieclip called main, and I am adding main to the stage via the document class. Once there, the user enters in some info in a text box, and then clicks the continue button, which sends main's playhead to frame 2. I have an ENTER_FRAME script that detects when frame 2 has been entered and it calls a function that sets a bunch of properties of MC's that exist only in frame 2. Except setting those properties throws a null object error. Evidently, it seems that since the MC's I want to access via code are not on frame 1 of main, my code can't target them. Is there a workaround to this or am I just approaching the setup completely wrong? Any tips would be super helpful. Let me know if you need any more info, I can try to explain it better. Thanks a bunch!!

senocular
12-18-2008, 11:35 PM
ENTER_FRAME fires before the frame is constructed. Flash Player 10 accounts for this with FRAME_CONSTRUCTED and EXIT_FRAME events that are just like ENTER_FRAME except the occur after object constructrion (FRAME_CONSTRUCTED) and after frame scripts (EXIT_FRAME).

If you're targeting FP9, you can either wait for a second ENTER_FRAME event or in that event handler, call stage.invalidate() and wait for the RENDER event.

xxneon
12-18-2008, 11:44 PM
you can also try to use this method too.. 'addFrameScript()'... its not documented but there is enough info on the net about it.. it would allow you to setup a method inside your document class .. and then in your constructor you could do somthing like this.
addFrameScript(1,theMethod);
i think the frames are referenced similar to array indexes.. 0 = frame 1, 1 = frame 2..

not sure if this is a good solution .. but it would work... no need for the ENTER_FRAME checker..

Blkhwks19
12-18-2008, 11:48 PM
Thanks guys, both those options are quick and easy workarounds. I'll definitely learn more about them since I know Ive run into this issue before, so this will help me down the road as well as right now. Thanks again!