The help says that the syntax is
package packageName { class someClassName { } }That is actually not correct - the "packageName" is actually the.package.path. For example,
package com.abc.MyClass { public class TWriteFile { } }must be stored in the following file and directory
com\abc\MyClass\TWriteFile.asAnything else will cause an error ... this is not in the help files.
Also, note that the public tag is required ... also missing from the help.
Sharing Code - How to specify a classpath
Edit / Preferences... / ActionScript / ActionScript 3.0 Settings...and paths for just the current project using
File / Publish Settings... / Flash Tab / Click Settings... next to ActionScript VersionBy default, Flash searches the current directory (shown as a dot) and $(AppConfig)/ActionScript 3.0/Classes, which is at
C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\ActionScript 3.0\Classes\These define the path to the beginning of the projectPath described in the previous section.
In the help, search for Modify the classpath and Set the classpath for ActionScript 3.0 for more information. Similar settings are used for configuring ActionScript 2.
Most of the examples described in the help files use packages where the main object is created by placing the package's name in the form's Document class property. In every case I've seen, the code is executed via the class constructor.
In every case
I have found nothing on this in the help - just a couple of days of trial and error before I gave up.
Note: This is an
Globals
5006: An ActionScript file can not have more than one externally visible definition: mcCommon.CRLF_ab, mcCommon.CRLF_mcIn order to define several global values in a library
C:\Adobe_Projects\Flash\jcamps\mcCommon\CRLF_mc.as C:\Adobe_Projects\Flash\jcamps\mcCommon\CR_mc.asThis is the contents of CRLF_mc.as - it just defines a constant I use.
package mcCommon{ /* 01-15-08 Start of file */ public const CRLF_mc = "\r\n";//#13#10 CR/LF - Carriage Return/Linefeed }The block comment with the date is just for QC, I find this useful and use it in most of my files.
This is the Flash code I used to test this method ... it works.
import mcCommon.*; var j:String; j='asd'+CRLF_mc+"secondtest"; trace(j); trace("test"+CR_mc+"line2"+LF_mc+"line3");
You can use as many *.as files as you like, but the code will not be executed until you call the public entry point.
This method is extremely inefficient, using 4 to 30 kilobytes to store only 50 bytes of data really eats up your hard drive. I can't believe that any intelligent person thinks that this is a good idea.
Note:
After many frustrating hours,
none of this was found in the help files.
I finally understood this after reading
Including External Source
include "Filename.as";
Notice that the import directive points to a project that contains a single public instance.
The include directive actually reads a file into the current source and compiles it there. These files must not include the project directive.
Unfortunately, because ActionScript 3.0 does not provide a conditional include directive (found in all real languages), you can not use this method to include the same information in multiple files.
No Overloaded Functions
However, it creates a problem for me because I want to convert some libraries to ActionScript 3.0.
Notes
On the other hand, it does contain some technical data that Adobe decided to hide from us.
Author: Robert Clemenzi - clemenzi@cpcug.org