Monday, November 15, 2010

Trace (message)

The command trace () is used to display something on the output panel. Usage of trace action is very useful in further programming later, as fault testing in a program line. An example of using trace action script as following:
  • Click frame 1, then open the action panel and typing the script: trace (1000); then run the movie by pressing CTRL+Enter. It will appear the text "1000" on the output panel.
  • Press Ctrl + W to return to the Stage. Next change the action in frame 1 become: trace ("hello how are you?"); Then run movie again. So it will appear in output panel as follows:

Sunday, November 14, 2010

OnClipEvent (event)

OnClipEvent is a script that is used by a movie clip to execute some other commands in a block event. Event parameters can contains:
  • load command will be executed when first movie clip loaded by the time line.
  • unload command will be executed when a movie clip is removed (omitted) from the time line.
  • enterFrame command will run continuously throughout the active frame.
  • mouseMove command will be executed when the mouse is moved.
  • mouseDown command will be executed when the mouse is pressed.
  • mouseUp command will be executed when the mouse is released.
  • keydown command will be executed when it detects a button pressed by using the action Key.getCode.
  • keyUp command will be executed when it detects a button released by using the action Key.getCode.

Advance understanding about this script will be formed in line with our practice in processing the action script.

Saturday, November 13, 2010

gotoAndStop() and gotoAndPlay()


Action gotoAndStop () is used to stop the movie at the desired frame. Frame can be filled by using desired frame number or frame label. Consider the following examples:

  • Create a ball movieclip and place to the left of the stage.
  • Click on frame 20 and then insert keyframe. Move ball position to the right stage.
  • Right-click on frame 10 and select create motion tween, it will form ball animation that moves from left to right in a loop.
  • Add new layer above the layer 1 and change its name to action.
  • Click on frame 10 action layer, insert keyframe, then open the action panel and typing action gotoAndStop (1);

  • Run the movie, then when ball reached the middle stage, ball will back and stop to the starting position in left of stage.

gotoAndPlay (frame)

Action gotoAndPlay () used to play the movie on the desired frame, as opposed to the action gotoAndStop ();

note: once when we find action gotoAndStop ("start"); the word "start" is frame label. To add frame label, input keyframe on the desired frame, open Properties panel and typing in <frame label> textbox.

Friday, November 12, 2010

Playing Movie using play();

Action play(); used to running frame that stoped because action stop();. For more detail see example as follow:
  • Continue step in last post (Stop Movie using stop();).
  • Click layer 1, then add new layer above layer 1 and change name to button.
  • Click frame 10 in button layer, then add new keyframe and create a button in center of stage using rectangle tool.
  • Select button that we make with rectangle tool and convert to symbol by pressing F8, type “play_btn” in name option then choose button in type option.
  • Select play button then open action panel and type this script:
on (release) {
//if button play is pressed then play next frame
  • Run movie by pressed CTRL+Enter. When ball is stop, press play button that we make and ball will move again. Action play(); in play button cause movie run again when button is pressed.

Thursday, November 11, 2010

Stop Movie using stop();

Action stop(); is used to stop running movie clip. For more details, see the following example:
  • Make a ball with oval tool, then convert to symbol with the name ball_mc.
  • Select ball_mc, then place it in the left of the stage.
  • Click on frame 20, then add a keyframe by pressing F6. Then move ball_mc to the right stage.
  • Right click on the timeline frame 10, then choose create motion tween.
  • Run the movie by pressing Ctrl+Enter. It will get a ball movement from left to right in loops.
  • Back to the stage by pressing the Ctrl + W, then add a new layer (action layer).
  • Click the action layer frame 10, then input keyframe by pressing F6. Still frame 10 in selection, open the action panel and typing action stop ();
  • Run movie by pressing the Ctrl+Enter, then the ball will stop when located in the center stage. This is caused due to the action stop (); so the movie stop.
  • Save the file.