Tag Archive for 'AS3'

Static Event Dispatcher

///	STATIC DISPATCHER ///

private static var
	_dispatcher:EventDispatcher;

public static function
addEventListener(p_type:String, p_listener:Function, p_useCapture:Boolean=false, p_priority:int=0, p_useWeakReference:Boolean=false):void {

  	if (_dispatcher == null) { _dispatcher = new EventDispatcher(); }
  	_dispatcher.addEventListener(p_type, p_listener, p_useCapture, p_priority, p_useWeakReference);
}

public static function
removeEventListener(p_type:String, p_listener:Function, p_useCapture:Boolean=false):void {

  	if (_dispatcher == null) { return; }
  	_dispatcher.removeEventListener(p_type, p_listener, p_useCapture);
}

public static function
dispatchEvent(p_event:MovieEvent):void {

  	if (_dispatcher == null) { return; }
  	_dispatcher.dispatchEvent(p_event);
}

TextField – available html tags

Read more about flash Player supports the following HTML tags:
Continue reading ‘TextField – available html tags’

Fuzzy search algorithm

source code

Another fun game concept from 長 健太

Controls
Movement: Arrow or [WASD] keys.
Fire / Start : [Z], [X], [.] or [/] key.

Liquid 10000

Another paint mechanic

Ink Tween

Generative labyrinth

Continue reading ‘Generative labyrinth’

Sacura petals fractal

Continue reading ‘Sacura petals fractal’

Loading External Classes with ApplicationDomain

When you load an external ActionScript 3 SWF into a Loader instance in another ActionScript 3 SWF you can have the loaded SWFs definitions be shared with the SWF handling the loading or you can have it completely separated. The location of these definitions is known as the Application Domain.

In ActionScript 3 there is a hierarchy of application domains that describes class relations. You can have application domains separated (thereby keeping definitions separated) or you can an application domain as the child of another application domain. A child application domain will use definitions in its parents’ application domains before it uses its own if they are defined in a parent.

When loading a SWF into another SWF you have 3 options for the placement of the loaded SWFs definitions:

  • new partitioned domain: create a new separated domain for the loaded SWFs definitions to live that will separate it completely from those definitions within the loading SWF.
  • current domain: load the definitions into the current application domain of the loading SWF. This will not overwrite existing definitions but it will add new definitions to those within the current application domain of the SWF doing the loading.
  • child domain (default): load the definitions into a new application domain that is a child of the application domain of the loading SWF. This will not affect the current application domain of the loading SWF but it will force the loaded SWF to use any duplicate definitions in the parent over its own

You specify application domains for loaded content within a LoaderContext (flash.system.LoaderContext) instance. This instance is then passed to the load() method of Loader (Loader.load()). For the domain of the current SWF, you can use ApplicationDomain.currentDomain ().

// child SWF uses parent domain definitions
// if defined there, otherwise its own
var childDefinitions:LoaderContext = new LoaderContext();
childDefinitions.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);

// child SWF adds its unique definitions to
// parent SWF; both SWFs share the same domain
// child SWFs definitions do not overwrite parents
var addedDefinitions:LoaderContext = new LoaderContext();
addedDefinitions.applicationDomain = ApplicationDomain.currentDomain;

// child SWF domain is completely separate and
// each SWF uses its own definitions
var separateDefinitions:LoaderContext = new LoaderContext();
separateDefinitions.applicationDomain = new ApplicationDomain();

// set loader context in load()
myLoader.load(request, separateDefinitions);

More information:

http://livedocs.adobe.com/flex/201/h…ng_162_09.html

http://livedocs.adobe.com/flex/201/h…ent_175_4.html