all groups > flash actionscript > august 2007 >
You're in the

flash actionscript

group:

Beginner Actionscript 3.0 Help


Beginner Actionscript 3.0 Help Bob Ralian
8/25/2007 10:43:54 PM
flash actionscript:
I'm just trying to get a dynamic text field to be populated by "Hello World"
using actionscript 3.0.

My flash file has a dynamic text field named "randomtext" on frame 10 of a
layer also named "randomtext". My understanding is adding this name to a
dynamic text field automatically turns it into an object that can be
manipulated with actionscript. In a separate layer called "actions" I have
added some actionscript at frame 1 that says:

import flash.text.TextField;
randomtext.text = "Hello World";

However, when I test the movie (using control>Text Movie), I get the following
error:

TypeError: Error #1009: Cannot access a property or method of a null object
reference.
at cookie_fla::MainTimeline/cookie_fla::frame1()

When I remove that actionscript code, the error goes away. Am I missing some
other step?
Re: Beginner Actionscript 3.0 Help dzedward
8/25/2007 11:20:10 PM
Re: Beginner Actionscript 3.0 Help Bob Ralian
8/26/2007 3:43:22 PM
That makes sense. I tested a simpler version of my movie all on one frame and
it worked. It seems odd to me that all of the variables are not available to
the movie until you get to them in the timeline. I would think you'd want the
number/script-crunching to happen at the beginning, rather than in the middle
where it could potentially interfere with the speed of the movie. I'll probably
just do what you suggested, but I'm curious. Is there a way to instantiate the
auto-variables (textfields, whatnot) at the beginning so you can begin
manipulating them immediately?
Re: Beginner Actionscript 3.0 Help SymTsb
8/27/2007 1:21:35 PM
Actionscript is handled in a top down frame by frame basis and always handled
in the compiler before the graphics are drawn to the screen. The only way to
instantiate at the beginning would be to dynamically code the text field in
frame one and add it to the display list when you need it.
AddThis Social Bookmark Button