Action Scripting 3.0

Alejandra Jarabo
MAT 116

Media Arts & Technologies. Santa Barbara City College
ACTION SCRIPTING STRUCTURES


DOT SYNTAX

Dot Syntax is a formatting convention to create quick and efficient phrases that refer to buttons, movie clips and other objects.

The “dot” • is used to indicate the properties or methods related to an object (there is no space in between the elements and the dot)

   

Ball_mc • stop ( ) ;
_______•________
  WHO      WHAT

WHO: is the INSTANCE NAME of your button or movie*.

WHAT: The Action that you want it to do/ The property that you want to reset/ The Method to apply

   ;   or semicolon marks the end of a statement (just like period marks the end of a sentence)

     

Ball_mc• gotoAndStop (5) ;
________•_________________
  WHO      WHAT                

METHODS are special pieces of script (they are based on Functions)
that use a parenthesis to hold the parameters (called in Flash Arguments

If I add "gotoAndStop" I need to ADD Where do I want to go, this is the part of the script that varies on each case.
The frame number (in this case) is the parameter, and it is placed inside the parenthesis.

Some Methods don't need Arguments to work, that is the case of:
stop()
play()
nextFrame()
nextScene()

     

Ball_mc • x=50 ;
________•________
  WHO      WHAT  


Ball_mc • alpha=0.3 ;
_______•__________
  WHO      WHAT    


square_btn • width = 200;

square_btn • height = 200;  

square_btn • visible = true;

square_btn • visible = false;  
 

OBJECTS have PROPERTIES that can be reset with Action Scripting:

x   Sets the horizontal position of an object in relation with the Stage origin (the left upper corner).
y   Sets the vertical position of an object in relation with the Stage origin (the left upper corner).

scaleX   Sets the value specifying the percentage for horizontally scaling a button instance.
scaleY   Sets the value specifying the percentage for vertically scaling a button instance.

rotation   Sets the the rotation of the button, in degrees, from its original orientation.
alpha  Sets the the alpha transparency value of the button specified (between 0 and 1).

height   Sets the height of the button, in pixels.
width  Sets the width of the button, in pixels.

visible   Sets a Boolean value that indicates whether the button specified is visible. Buttons that are not visible (_visible property set to false) are disabled: they don't work when they are not visible.

enabled   Sets a Boolean value that specifies whether a button is enabled. The default value is true.

 

* the Upper-Left coordinates of the Stage are (0,0)
If the object is inside of a Movie-clip the _x and _y properties set the coordinates in relation to the local coordinates of the parent movie clip. The button's coordinates refer to the registration point position.

 

Look at this page on Properties, from the Interaction Design II class: HERE 

     
   
WHY NAMING A SYMBOL'S INSTANCE ON STAGE

Animate/Action Scripting you can code an EventListener (using DOT SYNTAX) that gets attached to a Button OR a Movieclip on Stage.

In any of those cases you will have to name the instance of the Symbol on Stage through the Properties Panel Before you write the code.

The name of the symbol in the Library is irrelevant for this matter. If you don't name it through the Properties Panel it will have no name.

The reason for this is that you might have created several copies of the same symbol, in the same project, on the same frame on Stage.
If you didn't name each instance on Stage, Animate wouldn't know which one of them has to perform the action.

It is a good idea to name instances through this naming convention:

Button-instances should be named : "something_btn", so later on, when looking at the code, you easily recognize that the object is a button.
Movieclip-instances are usually named : "something_mc", so looking at the code, you can recognize it as the name of a movieclip.