|
Free Open Book
Macromedia Flash 8 Bible |
Storing Code in External FilesFlash 8 is easily extensible, as there are various areas in which you can place code. This can be the cause of major problems — because there are many available options, you need to make sure the code is correctly placed so your movie is manageable and easy to use. In Flash 8, you have the option to store your code in an external .as file. The #include CommandOnce you have an .as file to use in a project, it is easy to make the ActionScript within the file available to your movie. The #include command is used to load any code from an external file and put it in the Flash movie file (.swf) published or tested by Flash 8. If you edit the .as file included in your movie, the changes will not automatically become part of an already-published Flash movie file (.swf). The #include command is only executed at the time you publish or test the .swf file. This simple example shows you how to include an external ActionScript file in a movie.
Now that you know how to use the #include directive, you can start to store larger amounts of code within .as files. One of the primary benefits of using .as files is that you can easily share the same ActionScript code from one Flash document to another.
Import Script CommandIf you prefer not to use the #include command to incorporate the code in your Flash movie file (.swf) at run time, you can simply import the file directly into Flash 8 using the Actions panel.
Export Script CommandJust as you can import the contents of an external file, you can export the contents of the Script pane to an .as file. This will enable you to take advantage of the editing capabilities in the Actions panel while still leveraging the usefulness of external ActionScript files.
Team EnvironmentsWhen working with a team of developers on one project, it can get quite difficult to manage the development of an application. Many "newbie" applications are built within one .fla file, which poses a problem because only one person can work on the file at any given time. It can become very confusing and file versioning errors may occur. A great way to reduce dependency on other team members is to break the .fla file up as much as possible. This may include breaking a project into several Flash document files (.fla), which are then combined using the loadMovie() method command at run time. Another effective method is to use external code files for storing data. For each block of code performing a separate task, or each custom object you are using in your application, you can store the ActionScript in an external file. This makes it easy for many people to work simultaneously on one application.
ActionScript Libraries and ClassesWith Flash 8, you can build ActionScript routines (and even your own custom classes) suitable for re-use across a variety of situations. For instance, you may have a block of code that you use to initiate a connection to a server-side script, or a Flash Communication Server application. Storing such code in external code files is an easy way to include them in your next project without much effort. An ActionScript library is a set of code used for a specific purpose. It can be any block of ActionScript, from simple variable declarations to more advanced ActionScript objects. This sort of code is well suited for being stored in an external text file, and easily included in many projects.
|
Main Menu |
| 500 Juegos Gratis | 500 Giochi Gratis | 500 Jeux Gratuits | 500 Jogos Gratis | 500 Kostenlose Spiele |