论坛首页 Web前端技术论坛

JS和FLEX的相互调用

浏览 1477 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-02-27  
JS调用FLEX方法:

1.首页在MXML文件中定义供外部调用的函数:

ExternalInterface.addCallback("prevEx",prevExtentClickHandler);
  
   2.JSP中调用
function prevEx()
{
        swfobject.getObjectById("resGridFlex").prevEx();
}

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                        id="resGridFlex" width="100%" height="100%">
                    
        </object>
  

   flex如何调用JS方法:
1.在JS中定义函数
function CB_PointSelGeo(gridid){

}


2.在FLEX中调用JS方法
<mx:HBox>
                                <mx:Button label="楼宇" click="PointToInfo()" fontSize="12"/>
                                <mx:Button label="更多" click="PointSelectMore()" fontSize="12"/>
                        </mx:HBox>
                        <mx:Script>      
                                <![CDATA[
                                        private function PointSelectMore():void{
                                                ExternalInterface.call("CB_PointSelGeo('"+data.GRID_ID+"')");
                                        } 
                                        private function PointToInfo():void{
                                                ExternalInterface.call("CL_PointSelInfo('"+data.GRID_ID+"')");
                                        }
                                ]]>
                        </mx:Script>
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics