|
Introduction to ActionScript
Action
Are commands that give the designers and programmers
the ability to give flash movies interactivity and functionality. With
help of actions you can do more than simple animation and linear playback.

ActionScript
Is a programming language, used to create more complex
and interactive flash movies.
Syntax
Is an important part of every language and is the accepted
order in which sentences are constructed. Remember,
Actions always follow the syntax.
Comments
Act like a personal reminder and they do not
contain any instruction to flash. They just provide a space within your
code for you to remind yourself what you have done.
Example shows a comment: // this is a comment.
Comments in flash have a magenta color.
Code display in flash and their colors
Magenta for comments
Blue for actions and some other reserved words
Green for properties
Black or gray for everything else
The order of an action
Each basic action starts on a new line and ends with
a semicolon.
ActionScript can be attached to three things within
your movie
A keyframe
A button on the stage
A movie clip on the stage
Event and Event Handler
As mentioned before when we talk about ActionScript,
we are thinking about interactivity, meaning reacting and making things
to happen. In flash, interactivity is made up of "event" and
instructions that are given on how to act to the interactivity. We can
look at the events as our first programming block.
Events has two form. It can happen externally,the user presses
a button on the web site or typing on the keyboard or it can be something
less obvious and happening internally, like loading a movie clip or moving
to the next frame.
For the events in general flash ActionScript
follows the same pattern and they are:
1. ActionScripts are set up to detect a particular event.
2. Once the event occurs, a set of ActionScripts is executed to handle
the event, meaning the ActionScript that starts the second step above
is referred to as "event handler"
and always forms a pair with the main event.
Remember: events always have a corresponding
event handler, and also event-driven Actionscript brings the ability to
react to the unexpected as soon as it occurs. Meaning, they happen in
a random order, either alone or in group.
The simplest example of event / event handler in flash is a button.
The button works in this way:
1. The button is waiting for some user interaction, the user presses the
"event".
2. Then flash detects the event and run the ActionScript attached to it
meaning the "event handler".
3. The result is, the user can see something or hear something.
|