• Keep in touch:
  • Linked In
  • Twitter
  • RSS

How do I add use Actionscript in a movie?

Rather than define the behaviour of buttons and movie clips by creating individual action objects you can write the event handlers in Actionscript and use Translate to compile the code and add it to your movie.

ASCompiler compiler = new ASCompiler();
List<Action> actions = compiler.compile(new File(filename));

The script is compiled in a two step process. First it is parsed and then encoded for the version of Flash used in the movie. Depending on the statements used in the script the encoded data can added to either: a DoAction object to be executed when a frame is displayed:

new DoAction(actions);

a Place2 object to define a set of event handlers for a movie clip:

Place2.show(identifier, layer, x, y).setName("clip")

or to a DefineButton2 to define the set of event handlers for a button:

new DefineButton2(identifier, ButtonType.PUSH, records, actions);

Translate fully supports Actionscript 1.0.