flexmdi sans MXML
Update: I have slightly modified the code below to correct a mistake in the original post. Thanks to Brindy for pointing it out.
Every now and then I come across a request of how to use FlexMDI using only ActionScript. Its completely straightforward but I have finally gotten around to getting an example up. The first code snippet shows how to do this while still utilizing MDICanvas for some of the convenience it provides.
import flexmdi.containers.MDIWindow;
import flexmdi.effects.effectsLib.MDIVistaEffects;
private function init():void
{
var mdic:MDICanvas = new MDICanvas();
mdic.percentWidth = mdic.percentHeight = 100;
mdic.effects = new MDIVistaEffects();
var win1:MDIWindow = new MDIWindow();
win1.title = "First Window";
win1.width = 300;
win1.height = 200;
mdic.windowManager.add( win1 );
var win2:MDIWindow = new MDIWindow();
win2.title = "Second Window";
win2.width = 300;
win2.height = 200;
win2.x = 325;
win2.y = 50;
mdic.windowManager.add( win2 );
var btn:Button = new Button();
btn.label = "Awesome Button";
win2.addChild( btn );
addChild( mdic );
}
This next example shows how to turn a basic Canvas component into the container for an MDI implementation.
import flexmdi.containers.MDIWindow;
import flexmdi.effects.effectsLib.MDIVistaEffects;
import flexmdi.managers.MDIManager;
import mx.containers.Canvas;
private function init():void
{
var canvas:Canvas = new Canvas()
canvas.percentWidth = canvas.percentHeight = 100;
var mgr:MDIManager = new MDIManager( canvas, new MDIVistaEffects() );
var win1:MDIWindow = new MDIWindow();
mgr.add( win1 );
win1.title = "First Window";
win1.width = 300;
win1.height = 200;
win1.x = win1.y = 10;
var win2:MDIWindow = new MDIWindow();
mgr.add( win2 );
win2.title = "Second Window";
win2.width = 300;
win2.height = 200;
win2.x = 350;
win2.y = 100;
var btn:Button = new Button();
btn.label = "Awesome Button";
win2.addChild( btn );
addChild( canvas );
}
Hopefully this clears up some of the uncertainty around how to use FlexMDI without our good friend MXML but feel free to ask questions in the comments.
Both comments and pings are currently closed.
