六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 46|回复: 0

ASCB阅读笔记三、Runtime Environment

[复制链接]

升级  84.33%

137

主题

137

主题

137

主题

举人

Rank: 3Rank: 3

积分
453
 楼主| 发表于 2013-1-15 03:14:34 | 显示全部楼层 |阅读模式
1,检测用户浏览器安装的Flash Player版本
http://www.adobe.com/software/flashplayer/download/detection_kit
比较搞笑的是ActionScript 3.0有一个flash.system.Capabilities.version属性用来检测Flash Player版本,但是它不能在
Flash Player 8.5之前版本工作,所以这对Flash检测毫无用武之地。

2,检测操作系统

package {
  import flash.display.Sprite;
  import flash.system.Capabilities;

  public class Test extends Sprite {
    public function Test() {
      var os:String = Capabilities.os.substr(0, 3);
      if (os == "Win") {
        // Windows-specific code goes here
      } else if (os == "Mac") {
        // Mac-specific code goes here
      } else {
        // Must be Unix or Linux
      }
    }
  }
}


3,检测Player类型
if(flash.system.Capabilities.playerType == "Plugin") {  // do actions for Mozilla, etc. browsers} else if(flash.system.Capabilities.playerType == "ActiveX") {  // do actions for IE} else {  // do actions for no browser}

4,检测系统语言
var greetings:Array = new Array(  );greetings["en"] = "Hello";greetings["es"] = "Hola";greetings["fr"] = "Bonjour";// Extract the first two characters from the language code.var lang:String = flash.system.Capabilities.language.substr(0, 2);// Use a default language if the language is not in the listif (greetings[lang] == undefined) {  lang = "en";}// Display the greeting in the appropriate language.trace(greetings[lang]);

5,检测IME
flash.system.Capabilities.hasIMEflash.system.IME.enabledflash.system.IME

6,检测分辨率
var resX:int = flash.system.Capabilities.screenResolutionX;var resY:int = flash.system.Capabilities.screenResolutionY;// If the resolution is 240 x 320 or less, then load the PocketPC// movie version. Otherwise, assume the device is a desktop computer // and load the regular content.if ( (resX <= 240) && (resY <= 320) ) {  var url:String = "main_pocketPC.swf";}else {  var url:String = "main_desktop.swf";}loader.load(new URLRequest(url));

7,设置Movie的Scale模式
stage.scaleMode = flash.display.StageScaleMode.SHOW_ALLstage.scaleMode = flash.display.StageScaleMode.NO_BORDERstage.scaleMode = flash.display.StageScaleMode.EXACT_FITstage.scaleMode = flash.display.StageScaleMode.NO_SCALE

8,设置Movie在Player里的位置
stage.align = flash.display.StageAlign.TOPstage.align = flash.display.StageAlign.BOTTOMstage.align = flash.display.StageAlign.LEFTstage.align = flash.display.StageAlign.RIGHTstage.align = flash.display.StageAlign.TOP_LEFTstage.align = flash.display.StageAlign.TOP_RIGHTstage.align = flash.display.StageAlign.BOTTON_LEFTstage.align = flash.display.StageAlign.BOTTON_RIGHT

9,隐藏Flash Player的右键点击菜单项
stage.showDefaultContextMenu = false;
但是这只能部分隐藏

10,检测音频
flash.system.Capabilities.hasAudioflash.system.Capabilities.hasMP3

11,检测视频
flash.system.Capabilities.hasEmbeddedVideoflash.system.Capabilities.hasStreamingVideoflash.system.Capabilities.hasVideoEncoder

12,提示用户修改Flash Player设置
flash.system.Security.showSettings(flash.system.SecurityPanel.CAMERA);flash.system.Security.showSettings(flash.system.SecurityPanel.DEFAULT);flash.system.Security.showSettings(flash.system.SecurityPanel.LOCAL_STORAGE);flash.system.Security.showSettings(flash.system.SecurityPanel.MICROPHONE);flash.system.Security.showSettings(flash.system.SecurityPanel.PRIVACY);flash.system.Security.showSettings(flash.system.SecurityPanel.SETTINGS_MANAGER);

13,处理系统安全
当我们从另一个domain加载一个.swf文件到当前程序中时,我们可能想运行它访问本程序的ActionScript
flash.system.Security.allowDomain()flash.system.Security.allowInsecureDomain()flash.system.Security.loadPolicyFile()<?xml version="1.0"?><!-- http://www.mydomain.com/crossdomain.xml --><cross-domain-policy>  <allow-access-from domain="www.otherdomain.com" />  <allow-access-from domain="*.adobe.com" />  <allow-access-from domain="123.45.67.89" /></cross-domain-policy>// wildcards<allow-access-from domain="*" />// deny access to any domain except the current one<cross-domain-policy></cross-domain-policy>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表