FLASH 8 and CS3. Action Scripting 2.0

Alejandra Jarabo
MAT 116

Media Arts & Technologies division. Santa Barbara City College
BUTTONS IN FLASH . ACTION SCRIPTING 2.0

Action scripting is a LANGUAGE with Rules of Grammar and punctuation (SYNTAX RULES), that Flash uses to provide INTERACTIVITY.

INTERACTIVITY Is the digital structure that allows an Experience of Communication in which the Machine (via software), tracks and responds appropriately to any Actions (events)
triggered by the END USER (the person interacting with the computer and using the mouse).

Action Scripting 2.0 ___ BUTTONS IN FLASH

A Button is a symbol that is specifically prepared to act as an EVENT HANDLER for an "action".
(it is prepared to register the users' activity and trigger the response)

An Action is a piece of programming (a script) that allows to create a programmed response to a deliberate movement of the end-user (in this case, how the user uses his/her mouse to interact with a button)

 

 

Types of MOUSE MOVEMENTS or EVENTS that can trigger an action by the program:  
rollOver:      

The user is placing the mouse on top of a button (hot spot) in the program.
He/she is "over-flying" the HIT area of the button with their mouse.
(Usually alerted by the change of the button: Changes to RollOver position)

 
press:

The user is clicking the mouse.

This is exact moment when the user's finger has pushed the mechanical button in the mouse to its lower position
(there is a physical sound associated to it, wherein the term "click")
(the button changes to its Down stage)

 
release: The user has clicked the mouse, he/she has already pressed the mechanical button and is now letting it go.  
rollOut:

The user is abandoning the HIT AREA (rolling out of the area), after having entered (after RollOver)

This stage is unrelated to clicking, the user might or might not have clicked the button.

 

releaseOut:

After clicking (Press), the user is letting the mouse go to its normal position, but because
he/she was moving the mouse at the same time than pressing,
the releasing is occurring OUTSIDE the HIT AREA of the button.

 

 

 

 

Actions can be Attached to a frame (frame Actions) or to an object itself (to a Button or to a Movie Clip)

To attach an action to a frame, the frame should be selected, before you begging scripting.

To attach an action to a button, the button should be selected, before you begging scripting.

   

ATTACHING AN ACTION TO A FRAME IN THE TIMELINE:

The first thing that needs to be done in order to attach an action to a button, is to make sure that you are giving the user the opportunity to click that button.

The Classical way of doing so is to STOP the Main Timeline until the user decides what to do next.

The STOP action ONLY STOPS the timeline, you don't write anything inside the parenthesis. stop();

When you stop the main Timeline, you are creating a "Cross-road situation" where the user has to decide "which road to take next"
(each road is what will happen if you press the button).
We usually define this situation as "an INTERACTIVE MOMENT": the user needs to make a decision to get out of that moment (to go somewhere else).

   

How to STOP the main timeline:

To use Action Scripting you need to use the specific Action dialogue-window (open it with option_F9/alt_F9)
You will attach an "stop action" to a FRAME in the main timeline.
Call the layer ACTIONS.

   
 
 
     
ATTACHING AN ACTION TO A BUTTON:

After you have created a Stop in the Main Timeline you need to also "program the way out of that frame", by attaching an action to the button itself.

In the next animation you see how to program the button to trigger an action "on RollOver" State,

on (rollOver) { (the part where you define which State of the button is going to trigger the action is called the EVENT HANDLER).
After defining the Event handler you will
Open the Command with an open-brace ({), then move to a second line of code.
gotoAndStop(5); In the second line you write the Action itself (with the help of the Action pane on your left)
In this case you want to: move the play-head to frame number 5. gotoAndStop(5)
In Action Scripting grammar, every line of code finishes with a semicolon (;)

} To finish the action you need to close the command by closing the brace (})
     
How to attach an action to a BUTTON
Action: go to a frame number and stop in that frame

   

 

 
     
     

I have included a back button
that comes back to frame 1

on (release).

(so you can see it working several times)