views:

24

answers:

2

I am writing an ActionScript class and I don't know where the standard place to put it is.

In other words, where should I put the package in regards to the hierarchy?

In flash.myname.mypackage? What is the standard naming convention?

As you can probably tell, I haven't had a lot of experience writing ActionScript classes :)

+1  A: 

A lot of people will create a package like:

com.myname.mypackage

Avoid using flash in the package name as that is used for the official classes created by Adobe.

So in your folder you will most likely have something like:

Folder
  |-FLA file //if created with Flash
  |-com
     |-myname
          |-mypackage
                 |-class
Allan
+1  A: 

If you don't use a package (technically using the "default" package)...

package {
  // ...
  public class MyFancyApp extends Sprite {
    // ...
  }
}

then the MyFancyApp.as file should work in the same directory as your .fla file.

As Allan explained, packages are often nested - they have more than one part to them, such as:

package com.company.fancyproject {
  // ...
  public class MyFancyApp extends Sprite {
    // ...
  }
}

In which case, you would generally create a "com" folder next to your .fla file, and nest the company, and fancyproject folders inside that. The MyFancyApp.as would be inside the nested fancyproject folder, of course.

It's worth noting that to save yourself some grief, you could also just throw the .as file into a single folder called "com.company.fancyproject", if you're not planning any complicated package structures.

You can also change the location(s) that Flash looks for the source files under "Publish Settings", Flash tab, "Settings...", "Source Path" tab. By default there's one source path ".", which means the current directory. I usually replace this with "./src/" or "./as/" so that I can keep all the project code bundled up in a single folder, and so it's clearer where the code is.

aaaidan