Flex中通过和Security类中的常量(LOCAL_TRUSTED, LOCAL_WITH_FILE, LOCAL_WITH_NETWORK以及REMOTE)对比sandboxType属性检查应用程序当前安全沙盒设置的例子

By Minidxer | September 21, 2008

接下来的例子演示了Flex中通过和Security类中的常量(LOCAL_TRUSTED, LOCAL_WITH_FILE, LOCAL_WITH_NETWORK以及REMOTE)对比sandboxType属性,检查应用程序当前安全沙盒设置。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.         layout="vertical"
  4.         verticalAlign="middle"
  5.         backgroundColor="white"
  6.         creationComplete="init();">
  7.  
  8.     <mx:Script>
  9.         <![CDATA[
  10.             private function init():void {
  11.                 switch (Security.sandboxType) {
  12.                     case Security.LOCAL_TRUSTED:
  13.                         sandboxLabel.text += " (Local trusted)";
  14.                         break;
  15.                     case Security.LOCAL_WITH_FILE:
  16.                         sandboxLabel.text += " (Local with file)";
  17.                         break;
  18.                     case Security.LOCAL_WITH_NETWORK:
  19.                         sandboxLabel.text += " (Local with network)";
  20.                         break;
  21.                     case Security.REMOTE:
  22.                         sandboxLabel.text += " (Remote)";
  23.                         break;
  24.                 }
  25.             }
  26.         ]]>
  27.     </mx:Script>
  28.  
  29.     <mx:Form>
  30.         <mx:FormItem label="Security.sandboxType:" fontSize="16">
  31.             <mx:Label id="sandboxLabel" text="{Security.sandboxType}" />
  32.         </mx:FormItem>
  33.     </mx:Form>
  34.  
  35. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: Other | No Comments » | Tags: , ,

Search Posts