Flex中检查是否支持ExternalInterface API的例子

By Minidxer | March 11, 2008

下面的例子展示了如何检查Flex应用的容器(container) 是否支持ExternalInterface API。

下面是具体的例子以及源代码:


Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- http://blog.flexexamples.com/2008/03/10/checking-to-see-if-the-externalinterface-api-is-available-in-flex/ -->
  3. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  4.         layout="vertical"
  5.         verticalAlign="middle"
  6.         backgroundColor="white"
  7.         creationComplete="init();">
  8.  
  9.     <mx:Script>
  10.         <![CDATA[
  11.             import mx.controls.Alert;
  12.  
  13.             private function init():void {
  14.                 if (ExternalInterface.available) {
  15.                     ExternalInterface.call("alert",
  16.                             "ExternalInterface is available");
  17.                 } else {
  18.                     Alert.show("ExternalInterface is not available");
  19.                 }
  20.             }
  21.         ]]>
  22.     </mx:Script>
  23.  
  24.     <mx:ApplicationControlBar dock="true">
  25.         <mx:Button id="button"
  26.                 label="ExternalInterface.available"
  27.                 click="init();" />
  28.     </mx:ApplicationControlBar>
  29.  
  30. </mx:Application>

这个Demo的Msg框会破坏我的theme布局,所以去掉了。要看得直接到Peter那里察看好了。
原文作者:Peter deHaan 翻译:minidxer

Topics: Flex | Tags: , , , ,

Related Post

One comment | Add One

Leave a Comment

Name(*):

E-Mail(*) :

Website :

Comments :

Search Posts

Archives

Sponsored Ads