我试图将警报框限制为特定模块,它不应该超出模块范围。我保留了 2 个选项卡,每个选项卡都包含不同的模块。但是警报的范围是全球性的,它影响的是整个窗口,而不是仅限于模块区域。请看下面的代码。
主.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.modules.*;
public function createModule(m:ModuleLoader, s:String):void {
if (!m.url) {
m.url = s;
return;
}
m.loadModule();
}
public function removeModule(m:ModuleLoader):void {
m.unloadModule();
}
]]>
</mx:Script>
<mx:Panel title="Module Example"
height="90%"
width="90%"
paddingTop="10"
paddingLeft="10"
paddingRight="10"
paddingBottom="10"
>
<mx:TabNavigator id="tn"
width="100%"
height="100%"
creationPolicy="auto">
<mx:VBox id="vb1" label="Column Chart Module">
<mx:Button
label="Load" click="createModule(chartModuleLoader, l1.text)"/>
<mx:Button
label="Unload" />
<mx:Label id="l1" text="module1.swf"/>
<mx:ModuleLoader id="chartModuleLoader"/>
</mx:VBox>
<mx:VBox id="vb2" label="Form Module">
<mx:Button
label="Load" click="createModule(formModuleLoader, l2.text)"/>
<mx:Button
label="Unload"/>
<mx:Label id="l2" text="module2.swf"/>
<mx:ModuleLoader id="formModuleLoader"/>
</mx:VBox>
</mx:TabNavigator>
</mx:Panel>
</mx:Application>
模块1.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
<mx:Button label="Click 1 " click="ini()"/>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
public function ini():void
{
Alert.show("How","hello", 0,null,null,null,0);
}
]]>
</mx:Script>
</mx:Module>
模块2.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
<mx:Button label="Click 2 " click="ini1()"/>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
public function ini1():void
{
Alert.show("Click 2","hello", 0,this);
}
]]>
</mx:Script>
</mx:Module>
谢谢你