Open GoogleCodeExporter opened 9 years ago
You can do this yourself.
For instance in the example MDIExampleExplorer on the function addWindow you
can add
between the line "win.title = "Window " +
String(mdiCanvas.windowManager.windowList.length + 1);" and
"mdiCanvas.windowManager.add(win);" the following code:
var mdld:ModuleLoader = new ModuleLoader()
mdld.id = "mdld1"
mdld.percentWidth = 100
mdld.percentHeight = 100
mdld.addEventListener( ModuleEvent.PROGRESS, progressEventHandler)
mdld.addEventListener( ModuleEvent.ERROR, errorHandlerNPHModuleLoader)
mdld.addEventListener( ModuleEvent.READY, readyEventHandler)
mdld.url = "ModuleName.swf"
mdld.loadModule()
win.addChild( mdld)
You can then add the following functions:
private function progressEventHandler(e:ProgressEvent):void {
}
private function errorHandlerNPHModuleLoader( e:ModuleEvent):void {
Alert.show( "There was an error loading the module.\n" + e.errorText + "\nPlease
contact the Help Desk.")
}
private function readyEventHandler( event:ModuleEvent):void {
Alert.show( "readyEventHandler")
}
And the following imports:
import mx.events.ModuleEvent
import mx.modules.ModuleLoader
Of course that this is an academic example. In order to have an application you
can
create a menu that call the addWindow function with the appropriate module to
be opened.
Finally you must add modules to the project in order to compile them against the
application.
Paulo Jorge Dias
Original comment by paulojor...@gmail.com
on 30 Jun 2008 at 5:46
Hello Paulo,
I have success with your example, but I can´t apply to open two or more modules,
how make?
You have one example?
If it will have example of a menu calling two modules...
Thanks,
Original comment by rafaelfr...@gmail.com
on 3 Jul 2008 at 4:37
Explaining better:
One module but with two window(or more) loading two swf(or more).
Original comment by rafaelfr...@gmail.com
on 3 Jul 2008 at 4:56
Let me see if I understand.
You what the combinations of Windows and Modules:
Window | Module
1 | 1
1 | N
N | 1
N | N
If you want to call it from a menu (see examples on how to use the menu)
associate to
the “itemClick” event a function which calls a function like addWindow
passing as
parameter the data of the menu dataProvider.
On that function you can decide what to do based on the data field content, and
is up
to you to innovate.
Example of 1 window -> 1 or N Modules (using the MDIExampleExplorer.mxml file):
On the script area:
import mx.events.*;
//The menu data provider
[Bindable]
public var menuDP:Array = [
{label: "Module A", data: "moduleA.swf"},
{label: "Module A and B", data: "moduleA.swf moduleB.swf"},
{label: "Module A and B and C", data: "moduleA.swf moduleB.swf moduleC.swf"},
];
public function menuItemClickHandler(event:MenuEvent):void {
addModule( event.item.data)
}
private function addModule( appModules:String):void {
var win:MDIWindow = new MDIWindow();
win.width = 350;
win.title = "Window " + String(mdiCanvas.windowManager.windowList.length + 1);
var appModule:Array = appModules.split( " ");
for( var i:int = 0; i < appModule.length; i++ ) {
var mdld:ModuleLoader = new ModuleLoader()
mdld.id = appModule[i] + i
mdld.percentWidth = 100
mdld.percentHeight = (100 / appModule.length)
mdld.addEventListener( ModuleEvent.PROGRESS, progressEventHandler)
mdld.addEventListener( ModuleEvent.ERROR, errorHandlerNPHModuleLoader)
mdld.addEventListener( ModuleEvent.READY, readyEventHandler)
mdld.url = appModule[i]
mdld.loadModule()
win.addChild( mdld)
}
mdiCanvas.windowManager.add(win);
}
On the XML area, after the Button or replacing the Button:
<mx:PopUpMenuButton id="p1" showRoot="true" dataProvider="{menuDP}"
itemClick="menuItemClickHandler(event)"/>
In order to have multiple windows call the addModule functions multiple times
from
the menuItemClickHandler.
As stated previously the idea is to use the menu data field from menu
dataProvider to
dynamically do what you whant.
Paulo Jorge Dias
Original comment by paulojor...@gmail.com
on 4 Jul 2008 at 4:45
[deleted comment]
Hi Paulo,i want to ask.How to limit the modules so it can only call once,if the
user
click on for example Module A,and it was called before,it will not create a new
window..Thanks a lot..
Original comment by yongha...@gmail.com
on 26 Aug 2009 at 6:39
Original issue reported on code.google.com by
rcol...@gmail.com
on 26 Feb 2008 at 3:17