Flash MX prototyping allows you to extend your movies in ways you never thought possible. By using prototyping you can share an effect or function among several movies without the need to replicate the code. This leads to your movies being more efficient, smaller in size and easier to code. Prototyping is not for the faint of heart so if you’re new to ActionScript or just programming in general you may want to brush up on the basics first. This article will provide the foundations to begin prototyping for yourself as well as provide some solutions to commonly asked questions in the forum.
The prototype property can be located in the ActionScript panel under Objects->Core->Function->Properties->prototype.
You can declare and delete prototypes anywhere in your movie. A good idea is to write all of your source code in the first key frame of your movie. If you're familiar with FlashComm, then you'll know that Macromedia recommends this. One very good reason to do this is so that later on when your project is complete, it can be fairly straightforward to move your code into an external .as file. This provides many benefits such as being able to share code among several movies and sites. The examples used here are written in the first key frame of _root.
The breakdown of the above is that all movie clips are given a new function called centerAlign. This new function will align a movie clip to the middle of two user defined variables. This can be used to center a clip on the stage or within another clip assuming the registration point is 0,0. To activate the new function simply requires you to call it as you would another other function. This prototype is used in this article's example to center align the child movie.