Not yet rated
Tags:



Problem

As a developer, you may have a lots of custom ActionScript classes organized within packages to make your work easier and faster for creating flash apps. For this reason, you need to make all of these classes available for use in your projects without having to copy your ActionScript files to the directory where your FLA files reside.

Solution

When you set a source path, your packages and custom classes will be available for all your flash projects automatically, and all you have to do is type your code, importing only custom classes that you need for that specific app.

Detailed explanation

Alright,

This tutorial is short but it's very useful for flash developers.

Let's think you have a folder named "My ActionScript Classes" located in C: drive where you store all your custom classes arranged into packages.

Following this, let's consider you have the structure of packages below, within the folder "My ActionScript Classes":

demo > messages > DefaultMessage.as / CustomMessage.as
demo > system > CustomUser.as / CustomUserAdmin.as

Now, we can go to Adobe Flash CS4 Professional and make all changes we must do.

  1. Start Adobe Flash CS4;
  2. When the welcome screen appears, go to Edit > Preferences.
  3. A dialog box will be displayed. Select ActionScript in the Category box;
  4. Finally, hit the ActionScript 3.0 Settings button;
  5. In the SOURCE PATH field click on the Folder Icon and browse to C:\My ActionScript Classes directory and then click Ok to finish.

Right! Adobe Flash CS4 now knows where to look for our classes, if needed. To test it, create a new Flash File (ActionScript 3.0), open the Action panel and type...

 

import demo.messages.*;
import demo.system.*;

When you run the application, no errors are displayed for us. Because these packages really exist, and they are being referenced by Flash, so any flash file can use our classes, no matter where your FLA files reside.

You can also reference SWC files using Library Path or External Library fields, in that same window.

Once again, I hope this article was useful for everyone who uses Flash CS4.
Thanks for reading!!!
Bye! ;)


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes