views:

1792

answers:

3

I'm trying to write a RegEx for a code generator (in C#) to determine a proper class or package name of an AS3 class.

I know

  • Must start with a letter (capital or otherwise)
  • any other digit can be alphanumeric
    • cannot have spaces

Is there anything else?

+1  A: 

Here are some more valid classes.

Actionscript 3 classes (and packages) must start with a letter, "_", or "$". They may also contain (but not start with) a number.

public class $Test {}

public class _Test {}

public class test {}

maclema
+2  A: 

Although you can start class names with lower case letters and include underscores and dollar signs, the "naming convention" is to start the class name and each separate word with a capital letter (e.g. UsefulThing), and not include underscores. When I see classes like useful_thing it looks wrong because it's not the naming convention. Maybe your question should have said what are the valid names for an AS3 class?

Other than that I think you + maclema have it.

Iain
+2  A: 

The conventions for Class and Package naming as far as I've heard:

The package structure should use the "flipped domain" naming, with lowercase folders and CamelCAsed class names.

IE: import com.yourdomain.nameofsubfolder.YourSpecialClass;

This is reflected in all of the packages shipped with Flash and Flex. Examples:

import flash.events.MouseEvent; import flash.display.MovieClip;

There is also a convention of naming Interfaces after the functionality they add or impose as in: Styleable, Drawable, Movable etc... Many (including Adobe) also prefer to use an upper case "I" to mark interfaces clearly as such. I.E.

IEventDispatcher IExternalizable IFocusManager

Which are all internal Interfaces in the flash.* packages.

Martin