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

Home > Articles > Design > Adobe Creative Suite

  • Print
  • + Share This
Like this article? We recommend

Putting Your Hard Work to Good Use

Now you're all done with your generic script. The next thing you need to do is use it in a project. (Logical progressions such as this one are what separate the amateurs from the professionals).

  1. Launch Flash and open a new blank document.

  2. Set the Stage dimensions to 600 x 450 using the Document Properties dialog box (Modify > Document). Leave the background white and the frame rate at 12.

  3. Change the name of Layer 1 to actions.

  4. Select from one of the action layers, open up the Actions panel, and enter the following code to pull your generic script into your movie.

  5. stop();
    #include "generic_mcl.as"

    Don't add a semicolon to the end of the #include command. I'm not sure why, but this is the one time you don't need to terminate a command with a semicolon.

  6. Now you just need to use the loadClip method of the MovieClipLoader instance to load something. In this case, you'll load a beautiful photo of me in a moment of Zen snorkeling.

  7. the_loader.loadClip ("image.jpg", 1);

    Here, you load the image into level 1. The image is the same size as the Stage, so you won't see the movie's background. Your script should match Figure 5.

    Figure 5Figure 5 Stop, load a script, and then use it. It's fun.

  8. Save this file as master.fla into the same folder as your generic_mcl.as file.

  9. Choose Control > Test Movie to run the movie in the Preview window.

You should see the snorkeling photo appear immediately in the movie. If it doesn't load, it's time to go back and figure out what you did wrong.

From here, you can use this script in many ways, and you won't have to rewrite the initial matrix for the script. My suggestion is to make a folder on your hard drive somewhere that you'll always be able to find it, call it code_library, and compile yourself a secret stash of generic scripts.

If you modify this script into a preloader, for example, and all you have to do is make sure to include a progress bar animation in your movie called progressBar_mc, you have most of the work done next time you need a progress bar. Simply save a copy of the script you need into the same folder as your new project, modify it as necessary, rinse, lather, and repeat. You could turn this whole thing into a component and simply drag it into new movies whenever you need it. You could also spend some time learning about class files and turn your preloader into its own class. I'm just here to get you headed in the right direction.

If you don't like that photo of me snorkeling, just replace it with something else. You can load JPGs and SWFs into movies any time you want, and doing this will help keep file sizes down, allowing your movies to perform better, increasing the happiness level of your users, and getting you one step closer to a raise.

Until next time, stay vertical and don't get shredded.

  • + Share This
  • 🔖 Save To Your Account