Publishers of technology books, eBooks, and videos for creative people

Home > Articles

  • Print
  • + Share This
From the author of

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 3Figure 3 The Flash MX code window.

  1. 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 ""

    Next you're going to examine the file in a text editor.


    An ActionScript file is merely a text file saved with an .as extension.

  2. Start up your favorite text editor.

  3. Load the file named into the editor.

Figure 4Figure 4 The file in a text editor.

  • + Share This
  • 🔖 Save To Your Account