Modules
Modules are normal AS3 classes that can be instantiated through the describing boot.xml and can be reused in different projects.
Normally you split up an application into different modules. Typical modules for example are Navigation, Image, Text, Slideshow, VideoPlayer, ..
Lets see how a module that simply displays some text would look like;
package modules {
import flash.text.TextField;
import modular.core.module.DisplayModule;
public class Text extends DisplayModule {
private var textField:TextField;
public function Text() {
super();
textField = new TextField();
textField.text = "i'm a module";
addChild( textField );
}
}
}
If you include this module in your library you can create the module in your application with the following code:
<ModularApplication> <Page> <Assets> <Library path="library.swf" /> </Assets> <Modules> <!-- here we include our new module --> <Module class="modules.Text" /> </Modules> </Page> </ModularApplication>
You can easily pass data from your xml to the instance.
In most application you have a mixture of modules that are reusable over multiple projects and some that are specially made for this application.
Module types
As you could see in our custom module it extends from the modular.core.module.DisplayModule. Which is the base class for any module that is displayed in your application. For everything that has a visual representation in your application this is the class to extend from. Apart from being just a nomal Sprite the DisplayModule provides methods to show, to hide and to get the xml configuration.
In some situations there is no need for a visual module. For example you can create a module that handles the backend communication. In this case you can simply extends from the modular.core.module.Module instead of the modular.core.module.DisplayModule.
Comments