- It Works Like This
- Preparing to Work
- Using #include to Load ActionScript from a Text File
- Running Conditional Code with OnClipEvent
- The Time Zone Button Layer
- Using Functions to Repeat Common Tasks
- Keeping Time with the ActionScript Date Object
- Using Prototype to Extend the Date Object
- Updating in Real Time
- Updating the Mouse Time Zone
- Setting an Analogue Clock
- Setting a Row of Clocks
- Using setInterval to Update the Clocks
- Summary
- About This Article
Using #include to Load ActionScript from a Text File
How many times do you write the same old scripts? Wouldn't it be great to write a script once and be able to reuse it again and again across multiple movies and projects? This is exactly what #include will let you do. When you compile a Flash movie containing an #include statement, Flash replaces the statement with ActionScript loaded from an external text file. Notice that the syntax for this statement does not include a trailing semicolon.
Figure 3 The Flash MX code window.
In the Flash MX editing environment, select the maps movie and then open the ActionScript window. You'll notice that it contains a single line of code:
#include "timezones.as"
Next you're going to examine the file timezones.as in a text editor.
NOTE
An ActionScript file is merely a text file saved with an .as extension.
Start up your favorite text editor.
Load the file named timezones.as into the editor.
Figure 4 The timezones.as file in a text editor.