ActionScript Writing Pattern in Button

ActionScript Writing Pattern in Button
ActionScript Writing Pattern

ActionScript in flash can be write in 3 method, that is in button, movieclip, and at frame with different rule.

ActionScript Writing Pattern in Button

ActionScript writing steps in button are:

  • Make a box with rectangle tool. We also can make rounded rectangle by choosing rounded rectangle radius option.

  • Make static text “button” above box that we make before, by click text tool then open properties and arrange font, size and color. Open Properties panel (if not yet opened, choose menu window>properties). Always check that static text option is active in Text Type.

  • Select the box and text, then convert to symbol by press F8 button (menu insert>convert to symbol). Select button in behavior option then type button_btn in Convert to symbol name.



  • Double click this button to enter button edit mode. Note in symbol with button type is consist of 4 frame that is up, over, down and hit. Up showing normal condition in button. Over showing button condition when mouse at above button. Down showing button condition when pressed and hit is press area (sensor) of button.

  • Click over frame then input keyframe by pressing F6 button (menu insert>keyframe). Change color and size of button in over frame. For down and hit we can ignore it.

  • Press Ctrl+E to back in Main Stage. Click the button which is in selection condition, open action panel (press F9 or click menu windows>action if action panel not yet opened and check that writing mode is expert mode if using flash MX or Flash 8). Then type this script :
  • on(release){ //showing message in output panel when button is pressed trace(“button is pressed”); }
  • Run movie by pressing Ctrl+Enter. Then the button that we make is appear. Press the button, then in output panel we see “button is pressed” in output panel. Press Ctrl+w for back to stage.

Explanation ActionScript pattern in button is:
  1. Action in button must started with script on().
  2. Symbol “()” at on contain mouse event such release, press, dragover, rollout and others. Mouse event expressing event that will executed by the action when mouse is doing some event. For example : mouse event release is command in { } will run when mouse is press the button.
  3. Symbol { is starting script block. Script block is a group of command that will run in a whole movie event.
  4. Symbol // is expressing coment. Line with this symbol wont executed by actionScript, but it very helpful for give information in action script that our write.
  5. Line with command trace(“button is pressed”) is line command. Command in button must written at a mouse event block. In the end of writing command is always closed by symbol “;”.
  6. Symbol } is the end of script block.


Post a Comment

0 Comments

-------- MASUKAN KODE IKLAN 1 --------
-------- MASUKAN KODE IKLAN 2 --------
-------- MASUKAN KODE IKLAN 3 --------
To Top