sfmultimedia.net

sfmultimedia :: actionscript salons :: as fundamentals

/

Actionscript Fundamentals

If you're basically living in an

on (press)

and

gotoAndPlay(10)

world, this presentation is a great place to start. We cover Flash structure, dot syntax, variables, functions and branching behavior. In short, we explain all those little essentials which can get you away from the timeline and into code.

Relevance/availability: This material was written in Flash MX and Flash MX 2004 (Players 6 and 7). The concepts are still pretty relevant. If I were to re-do this today, I'd almost certainly add information on strict data typing.

Presentation slides (swf)

The sliding ball. An example (seen at the Salon) of a ball which eases to a destination when the mouse is clicked. This demonstrates Flash 5 onClipEvents (load, mouseDown and enterFrame) and Flash MX dynamic handlers (onMouseDown and onEnterFrame). I've also defined speed as a _global variable, so you can see how that works.

View the swf
Download the fla

Scope Chain. This example shows how you can use dot notation to drill up or down to affect MovieClips, variables, text fields, etc within different scopes. We also demonstrate that there is no limit to the number of times we can drill up using _parent._parent._parent...

View the swf
Download the fla

Buttons and Decisions. This one demonstrates two fundamental concepts: (1) button code and (2) decision trees. The button code should be self-evident when you see the examples. The decision tree uses the syntax:

if (something){
   execute some code;
} else if (something else){
   execute so different code;
} else {
   execute yet another bit of code;
}

If the 'something' inside the parenthesis resolves to 'true', then everything within the following brackets will be executed. When we use 'else' without an 'if (something else)' we're saying 'if nothing else happens, do this'.

View the swf
Download the fla

Functions. A very simple example showing how to use a function.

View the swf
Download the fla