Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 50

Programming actionscript 3.0
Table of Contents

Advertisement

import example.myInternal;
use namespace myInternal;
public class Helper
{
private static var _timeStamp:Date;
public static function someTask()
{
_timeStamp = new Date();
}
myInternal static function get lastCalled():Date
{
return _timeStamp;
}
}
}
The fourth file, NamespaceUseCase.as, is the main application class, and should be a sibling
to the example folder. The NamespaceUseCase class will also import the
namespace and use it to call the two static methods that reside in the other packages. The
example uses static methods only to simplify the code. Both static and instance methods can
be placed in the
myInternal
// NamespaceUseCase.as
package
{
import flash.display.MovieClip;
import example.myInternal;
import example.alpha.Utility;
import example.beta.Helper;
use namespace myInternal;
public class NamespaceUseCase extends MovieClip
{
public function NamespaceUseCase()
{
Utility.someTask();
Utility.someTask();
trace(Utility.taskCounter); // 2
Helper.someTask();
trace(Helper.lastCalled);
}
}
}
50
ActionScript Language and Syntax
namespace.
// import namespace
// import Utility class
// import Helper class
// [time someTask() last called]
myInternal

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents