Thus far in this book, you have seen that external ActionScript files are not necessary. In fact, creating external AS files would be yet another step in the process of building an application in Flash, so what would be the reason behind it?
ActionScript, as mentioned in previous chapters, is an object-oriented language, meaning that almost every piece of code is based on an object class. But this doesn't directly address the reason behind creating external ActionScript files; it is just the basis behind the reason.
It's no secret that Flash 8 is designed to be used by design and development teams in harmony, and that is where externalizing core ActionScript requirements for a given application comes in handy. A developer can create object classes to be used by designers or other developers easily and quickly at the same time that the designer is creating the visual aspects of the application, thus keeping design, content, and function all separate.
Using external AS files also allows multiple applications to use the same file at the same time. Think of it this way: Imagine having to define the MovieClip object in each file you wanted to use it. It would be very difficult to create the exact same class each time you needed a movie clip, not to mention the repetitiveness of it. But because the MovieClip object is defined already, we can simply use it in Flash and not have to worry about how the movie clip was actually created. Another example might be certain effects or transitions that are prevalent throughout a huge corporate site. It would be difficult to match the effects exactly if you did not create them in the first place. And copying and pasting code from other projects can sometimes be tricky if you are missing a variable. Thank fully, the development team created an external ActionScript file that contains a simple API for all the effects and transitions that you can simply include and use in your files, which is quite a time saver.
As we go through this chapter, all of this will begin to make more sense and you will begin to see the advantages in creating external ActionScript files.