添加了功能的customcomponent我創建了一個自定義組件(名爲customtitlewindow)的代碼,其中如下:我怎麼叫的柔性
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow 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="vertical" width="400" height="300"
xmlns:comp="components.*"
showCloseButton="true"
keyDown="detectescapekeypress(event)"
creationComplete="this.setFocus();"
close="PopUpManager.removePopUp(this);"
paddingTop="40">
<fx:Script>
<![CDATA[
import mx.managers.PopUpManager;
public function detectescapekeypress(event:KeyboardEvent):void
{
if(event.charCode == Keyboard.ESCAPE)
{
PopUpManager.removePopUp(this);
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</mx:TitleWindow>
現在我又創建了一個組件(名爲deleteconfirm)的調用上面的一個是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<mx:Container xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300" xmlns:components="components.*">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<components:customtitlewindow title="custom title window">
<s:Label>
<s:text>this is the custom text for deleteconfirm.</s:text>
</s:Label>
<s:Button label="ok">
<s:click>
<![CDATA[
Alert.show("Hello world!", "title");
]]>
</s:click>
</s:Button>
</components:customtitlewindow>
</mx:Container>
(主文件)現在上的按鈕,我呼籲上述(第二個)的點擊如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
]]>
</mx:Script>
<mx:VBox width="100%" height="100%">
<mx:Button label="Delete Record">
<mx:click>
<![CDATA[
var ctd:deleteconfirm = new deleteconfirm();
ctd = deleteconfirm(PopUpManager.createPopUp(this, deleteconfirm, true));
]]>
</mx:click>
</mx:Button>
</mx:VBox>
</mx:WindowedApplication>
我的主要目的是爲了向最終用戶顯示的所有彈出窗口在按下退出鍵時關閉所有彈出窗口,並在點擊標題欄上顯示的關閉按鈕時關閉所有彈出窗口。
但在「退出鍵」上按下什麼都沒有發生。
我該怎麼做?
有什麼不對?請糾正我以往任何地方錯誤的地方。
謝謝
感謝您的回答,但我認爲您的解決方案會打敗我的問題的目的。我不想重複escapekeysequence的代碼。 – 2011-04-10 10:47:37