flexmdi sans MXML
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.addChild( win1 );
var win2:MDIWindow = new MDIWindow();
win2.title = "Second Window";
win2.width = 300;
win2.height = 200;
win2.x = 325;
win2.y = 50;
mdic.addChild( 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.


on March 12th, 2008 at 2:34 pm
hi,
does that mean that it can be used in a pure actionscript project and not a flex project?
thanks!
on March 12th, 2008 at 2:43 pm
Unfortunately, no. MDIWindow is a subclass of Panel. Sorry.
on March 28th, 2008 at 9:21 am
Thanks for this soft!
When load image 640x480 in windows from example code
http://boris3gl.narod.ru/PV3D/WOW/WowStepSwitch/mdi.html
don't see all image
when use resize function
http://boris3gl.narod.ru/PV3D/WOW/WowStepSwitch/mdi1.html
all work , but when event's are windowMaximize,
windowRestore how get win.width and win.hight ?..
some code for function for resize
private function windowResiseForFocusedWin(event:Event):void{
var mgrEvent:MDIManagerEvent = event as MDIManagerEvent;
var tmpWin:MDIWindow = mgrEvent.window;
var tmpImg_ar:Array = tmpWin.getChildren();
if(tmpWin.getChildren().length > 0){
var tmpImg:Image = tmpImg_ar[0];
var tmpImgW:Number = tmpImg.width;
var tmpImgH:Number = tmpImg.height;
tmpImg.scaleX = tmpImg.scaleY = tmpWin.width/640;
//fool code, delete this and windowMaximize,windowRestore no work
if(mgrEvent.type == 'windowMaximize'){
tmpImg.scaleX = tmpImg.scaleY = 1;//tmpWin.width/640;
tmpImg.x = (mdiCanvas.width - tmpImg.width)/2; //no work
}
if(mgrEvent.type == 'windowRestore')
tmpImg.scaleX = tmpImg.scaleY = 0.5;//tmpWin.width/640;
}//if
}//windowResise()
rest code
http://pastebin.com/m5bbb92b5
on March 28th, 2008 at 11:12 am
Hi Userk,
I'm sorry but I don't understand your question.
Ben
on March 28th, 2008 at 12:23 pm
Click Add 2-3 windiw, then Tile or Cascade - win and image start resize . When click windowMaximize,windowRestore - image don' t resize with windows.
on March 28th, 2008 at 12:53 pm
Ah, I see. Unfortunately I think you are running into an issue that has been brought up a few times recently. The RESIZE events are only dispatched from manual resize events using the draggable edges/corners of the windows. Things like maximize, restore, tile, etc do not trigger these events.
We are looking into implementing this in a future version though.
Sorry,
Ben
on March 28th, 2008 at 1:13 pm
Thanks . Wait for future version and finished proect later
http://boris3gl.narod.ru/PV3D/WOW/WowStepSwitch/WOW_SPIRAL.html
Next question,( sorry)
when use
win.horizontalScrollPolicy = 'false' ;
win.verticalScrollPolicy = 'false';
all work, but when after this use
win.horizontalScrollPolicy = 'true' ;
win.verticalScrollPolicy = 'true';
no work ?
how dispatch to this?
on May 16th, 2008 at 5:31 am
Hello and congratulation for your works.
i would like to create a main application that manage windows in order to open external MXML Components/Files in each window .. is that possible ?
thanks for your help
fred from Mauritius
ps: sorry for my poor english
on May 16th, 2008 at 9:04 am
Hi Fred,
Yes, you can definitely load modules into MDIWindows and/or use SWFLoader to load external SWFs into them. A full discussion of those is too large and complex to be had here but there is lots of good info in the docs.
I have to say I think its pretty cool that someone as far away as Mauritius reads my blog. :) Best of luck with your application!
Ben