Flex3 代码 <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" borderStyle="outset" width="400" height="290" creationComplete="init()" xmlns:local="*" borderColor="#063D64"> <mx:Label x="0" y="0" text="VPN客户端" width="350" fontWeight="bold" height="21" id="title"/> <mx:Button x="350" y="0" width="21" height="21" click="minsizeHandle()"/> <mx:Button x="374" y="0" width="21" height="21" click="closeHandle()"/> <mx:Image x="0" y="21" width="100%" height="80" source="@Embed('xx.jpg')" /> <mx:Label x="77" y="119" text="用户名:"/> <mx:Label x="87" y="157" text="密码:"/> <mx:TextInput x="125" y="117" width="198" id="login_user"/> <mx:TextInput x="125" y="155" width="198" id="login_pass" displayAsPassword="true"/> <mx:CheckBox x="87" y="196" label="在远处网络上使用默认网关(需要重新连接)" width="236" id="checkbox_remote"/> <mx:HRule x="0" y="21" width="100%" height="1"/> <mx:Button x="229" y="226" label="登录" width="70" click="loginHandle()"/> <mx:Button x="307" y="226" label="退出" width="70" click="logoutHandle()"/> <mx:Label x="10" y="259" width="380" id="tip"/> <mx:HRule x="0" y="249" width="100%"/> <mx:Script> <!--[CDATA[ import flash.system.fscommand; import flash.events.Event; private function init():void { flash.external.ExternalInterface.addCallback("command", command); title.addEventListener(MouseEvent.MOUSE_DOWN,MouseEventFunc); } public function command(cmd:String):void { tip.text = cmd; } public function MouseEventFunc(evt:MouseEvent):void { switch (evt.type) { case "mouseDown": fscommand("title", "mouseDown"); break; } } private function closeHandle():void { fscommand("close", "xxclose"); } private function minsizeHandle():void { fscommand("minsize", "xxminsize"); } private function loginHandle():void { var args:String; args = login_user.text + " " + login_pass.text + " " + checkbox_remote.selected; fscommand("login", args); } private function logoutHandle():void { fscommand("logout", "xxlogout"); } ]]--> </mx:Script> </mx:Application> 新建一个对话框工程,添加ShockwaveFlash控件,为控件创建一个实例成员和交互代码 ShockwaveFlash m_FlashCtrl; //对话框初始化swf CString szFlashPath(m_FlashCtrl.GetModulePath()); szFlashPath += "test.swf"; m_FlashCtrl.LoadMovie(0, szFlashPath); MoveWindow(0, 0, 400, 290); m_FlashCtrl.MoveWindow(0, 0, 400, 290); //消息映射,与flash交互 BEGIN_EVENTSINK_MAP(CUIShowDlg, CDialog) ON_EVENT(CUIShowDlg, IDC_FLASH, 150, OnFsCommand, VTS_BSTR VTS_BSTR) END_EVENTSINK_MAP() void CUIShowDlg::OnFsCommand(LPCTSTR command, LPCTSTR args) { if( ! strcmp(command, "login") ) { CString strCmd = "<invoke name=/"command/" returntype=/"xml/"><arguments><string>Helloworld</string></arguments></invoke>"; m_FlashCtrl.CallFunction(strCmd.GetBuffer(0)); } else if( ! strcmp(command, "logout") ) { } else if( ! strcmp(command, "title") ) { if( ! strcmp(args, "mouseDown") ) { SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, 0); } } else if( ! strcmp(command, "close") ) { this->EndDialog(0); } else if( ! strcmp(command, "minsize") ) { this->ShowWindow(SW_SHOWMINIMIZED); } else { } }