Skip to main content
Participating Frequently
June 20, 2009
Answered

Need really basic help

  • June 20, 2009
  • 1 reply
  • 716 views

I've never used Flash or ActionScript before, and I'm very frustrated at trying to do something very simple:

I just want to write an ActionScript 3 that prints "Hello World" to a console. I'm not trying to run it in the web, have a GUI, or anything else. Can somebody give me step-by-step instructions for how to do this with Flash CS4 on OS X?

This topic has been closed for replies.
Correct answer

Didn't work. See screenshot and error message description.


Ctrl-Enter compiles the movie. Or Control Menu > Test Movie and you will see the hot key listed. If you were not allowed to enter script as you described, before you started a new movie, then you had an object selected... select a keyframe and you can enter script.

1 reply

June 20, 2009

I'm not exactly sure what you mean by 'to a console' but there's a couple of ways. 1 - you can use the trace command, which is helpful in debugging as well. Simply open the Actions panel in Flash and do:

trace("Hello World");

When you run it, you'll see the trace in the Output panel.

2. You can add a dynamic text field to the stage and output into that. Click the Text tool in the tools menu and draw out a text region on stage. In the properties panel change the text type to Dynamic Text (little drop down on the left side...) right under that give the text field an instance name such as myText - this allows you to reference the field from ActionScript. Click the key frame in the timeline as you can't add script to an object and the open the Actions panel and enter: myText.text = "Hello World";

Run it (Ctrl-Enter) and you should see the output in your field. PS - when you make the field, change the text color to black or something to be sure you can see it.

The Help is really good in Flash, there's examples for most everything and there's plenty of good tutorials on line. kirupa.com is a great site with lots of info, among others.

Participating Frequently
June 20, 2009

Hi dmennenoh - option #1 is exactly what I want to do. However, when I open the actions panel, I get a new window that says "Current selection cannot have actions applied to it." The text is not editable; how can I type in the trace command?

I'm not trying to associate my ActionScript with any visible object - I just want to have a little testing script where I can start teaching myself ActionScript, independent of the GUI.

Participating Frequently
June 20, 2009

OK, I made a little progress - starting a new Flash project from scratch lets me open the Actions panel without getting that message. I can type in the command, just like this:

trace("Hello World");

But I don't know how to run it. I tried doing Debug->Debug Movie, but then I get a compiler error that says:

1087: Syntax error: extra characters found after end of program.

I don't understand this, because the semicolon is the last character in my program.