Topic: Newbie Flash Question - Textfields

I'm an experienced programmer, but a Flash/ActionScript newbie.  I've got a couple of Flash & AS books on order from Amazon, but I'm impatient to get a widget up and working and have a (I think) simple question:

Using the example webcam widget, I'm creating a near-clone of that script which is grabbing an image from a different web cam.  I've figure out how to scale the image and render some static text, but I need to display a timestamp on the image as well.  The basic code to do that turned out to be pretty easy, but I've realized I need to provide an all-black rectangle background to be able to consistently read the text -- if I render it directly on the webcam image the background color sometimes washes out the text.

My problem is that I really don't understand the display/rendering order of ActionScript (or perhaps even the programming model).  Is there one script per .fla file?  --or one script per object?  --or something else?

I currently have two layers in my .fla file -- on called 'Camera' and one called 'Background'.  'Background' just  contains a black rectangle. 'Camera' has the script attached to it -- it's pretty much a clone of the example webcam .fla file.  It correctly renders the webcam image and I can do createTextField("xxx",...); xxx.text = "blah"; and it renders on top of the webcam "movie" just fine.  I can order the layers so that the black rectangle shows up "on top" of the camera layer -- but how do I render text on top of the rectangle?

I thought perhaps I could name it explicitly in the script (i.e., Background.createTextField("xxx",....), etc.)  -- but this doesn't appear to work.  What is the correct way to do this?

-M.

2 (edited by jvc 2007-11-28 20:33:27)

Re: Newbie Flash Question - Textfields

Since you are an experienced programmer I would suggest trying to keep all of your code in the first frame of the main Timeline on an empty layer. You'll find it's easier to maintain as you get more experience with it.

Flash lets you put your code everywhere though.

To answer your specific question..
Create a new Layer on the main timeline and draw a TextField with the text tool. Select it and in the Properties pallette name the instance txtTimeStamp. Make sure it is a dynamic text type in the properties palette.

Create an empty Layer in the main Timeline and name it "Actions". Select the first frame in that Layer, Open the Actions palette and put this code:

this.stop();
this.txtTimeStamp.text = "WHATEVER";

Hope that gets you started in the right direction.

Re: Newbie Flash Question - Textfields

Is the layer rendering order from top to bottom or bottom to top (of the layer list in Flash CS3)?  If I have my 'Camera' layer and then the 'Background' layer (which will contain the textfield as you suggest), do I place it above or below the camera layer so the text is rendered on top of the webcam image?

-M.

Re: Newbie Flash Question - Textfields

It renders top to bottom. I was suggesting creating a new layer that just contains your textfield (I always recommend keeping one layer per element). This way you can adjust the layering on the timeline