ITeye博客

Flex如何模块化

牧羊人 · 2010-05-26 14:00 · Web前端 · Flex · XML · Markdown

创建模块 基于mxml的模块,在你的工程右键->new->mxml Module


<<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" 
		   xmlns:s="library://ns.adobe.com/flex/spark" 
		   xmlns:mx="library://ns.adobe.com/flex/mx" layout="absolute" width="400" height="300">
	<fx:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
	</fx:Declarations>
</mx:Module>


基于as的模块


package
{
    import mx.modules.Module;
    public class General extends Module
    {
       public function General()
       {
           super();
       }
    }
}

加载模块,使用ModuleLoader加载;

 
<mx:ModuleLoader url="test.swf" />

使用ModuleManager加载


 Private function creationHandler():void
{
_moduleInfo =
ModuleManager.getModule( 'ContactList.swf'
);
_moduleInfo.addEventListener( ModuleEvent.READY,
moduleLoadHandler );
_moduleInfo.load();
}
Private function moduleLoadHandler(evt:ModuleEvent):void
{
canvas.addChild( _moduleInfo.factory.create() as
DisplayObject );
}

创建弹出模块


mx.managers.IPopUpManager
      Var general:ModuleLoader
general=ModuleLoader(mx.managers.PopUpManager.createPopUp(this,ModuleLoader));
           general.url="test.swf";

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。