Coder Social home page Coder Social logo

as3-parsley-modules's Introduction

AS3 Parsley Modules

The project provides an AS3-only module framework based on the Parsley application framework. Parsley supports Flex Modules by default but provides no alternative for AS3-only projects.

The project is currently in it's early stages. Further implementations, examples and documentation will follow.

Usage

The first step is to initialise the context. Therefore, pass the provided DefaultModuleContext class to the ActionScriptContextBuilder.

ActionScriptContextBuilder.buildAll([DefaultModuleContext, 
	YourOwnContext]);

This should happen in your main application, which then loads the other modules.

To define a module, the base class has to implement the Module interface. Compile these module then to its own SWF file (e.g. DemoModule.swf).

All modules then have to be registered in the ModuleConfig (you can inject the config, because it is in the context).

moduleConfig.registerModule("demo_module", "DemoModule.swf");

To trigger the loading, a module can either directly access the ModuleLoader (inject it), or better use the Parsley message system. This way you can send a message which your target module should receive. If the module is not loaded yet, the event will be intercepted by the framework until the module has been loaded and initialised. This happens automatically, so the sender side does not have to take care of the module loading. Afterwards the event will be proceeded to the corresponding module.

To receive this behaviour you have to follow these two steps.

  1. Create a abstract message class that your module should receive/listen for:

    class AbstractDemoMessage implements ModuleMessage { // All messages that the corresponding module should // receive have to extend this class. }

Note, that the message has to implement ModuleMessage.

A concrete message can than look like this:

class ShowItemMessage extends AbstractDemoMessage
{
	public var item:Item;
	
	function ShowItemMessage(item:Item)
	{
		this.item = item;
	}
}
  1. Register your abstract message type to a specific module:

    moduleConfig.registerModule("demo_module", "DemoModule.swf", AbstractDemoMessage);

Now, each time you dispatch an ShowItemMessage (either from the main application or another module) the corresponding module will be loaded (if not yet). All message handlers for this event will be called afterwards.

Upcoming features

  • Support of multiple triggers while a module currently loads
  • Support of module unloading
  • More sophisticated module initialisation (scopes, contexts)
  • More sophisticated module loading (ApplicationDomains)
  • Provide access to the loading progress

as3-parsley-modules's People

Stargazers

 avatar Antoine Lassauzay avatar Mattes Groeger avatar Meinhard Gredig avatar

Watchers

Mattes Groeger avatar James Cloos avatar  avatar

Forkers

stephanpartzsch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.