Class definitions typically belong in their own .as file for either ActionScript 2 or 3. ActionScript 3, however, allows you to include additional helper classes within a single .as file in addition to your primary class.
Additional classes defined in an .as file are defined after a package block and are visible only to the primary class (or function) in the package block or other helper classes in the same file.
ActionScript Code:
package {
class MyClass {
function MyClass() {
var helper:MyHelper = new MyHelper();
}
}
}
class MyHelper {
function MyHelper() {
var helper:HelpersHelper = new HelpersHelper();
}
}
class HelpersHelper {
function HelpersHelper () {
}
}
Remember that only one class can be defined in a package block. Additional helper classes defined in the same file are not part of the package and can be used only with the packaged class in the same file.
0 评论:
发表评论