Introduction to Flash

ActionScript is the programming language used by Flash. In the early versions of Flash it was fairly limited, but it has grown into a full-blown object-oriented programming language. When we talk about object-oriented programming, it means that you can define a class with properties and methods, then quickly create instances of that class. In addition to many classes that are built-in to Flash, you can also create new classes. Some of the classes that are built-in to Flash include arrays, strings, date and time, movie clips, text boxes, radio buttons, sliders and other components, a math class with functions to find a random number, to round, and so on. Like any modern programming language, Flash has primitive operations like variable declaration, if-else statements, and loops.
Without any other directions a Flash movie plays the frames in sequence and starts over when it gets to the end. We can add ActionScript to a frame to tell it to stop or go to a different frame. Let’s suppose that we have a movie with 20 frames. Instead of playing the movie over from the beginning, we would like to play from the beginning the first time, but play from frame 5 when it gets to the end. We could add the following code in frame 20: gotoAndPlay(5); We could add the command stop(); in frame 20 if we wanted the movie to just play once.

Object Oriented Programming
Modern programming languages use objects to make it easier to write large applications. An object is an instance of a class. A class is a definition that includes both properties and methods, or functions. Buttons, and movie clips are examples of objects. They have properties such as color, size, and position on the screen. They have functions that tell what to do when they are clicked, when the mouse moves over them, and other events. After we have defined a class, we can create an instance of that class called an object. There are many classes built-in to Flash such as buttons, movie clips, strings, date and time, etc.

Flash movies are event driven. We write functions in ActionScript3 that tell the movie what to do when a particular event happens. Events include clicking a button, moving the mouse, pressing a key, when a file finishes loading, when a sound finishes playing, or when a frame is entered. If we do not specify what to do when an event occurs, it does nothing to handle that event.

NEXT: Getting Started