3.2.检测操作系统

问题
我要知道客户端的操作系统。
解决办法
使用flash.system.Capabilities.os 属性
讨论
ActionScript 3.0中,flash.system.Capabilities.os 属性返回操作系统名称和版本字符串。值可能包括Windows XP, Windows 2000, Windows NT, Windows 98/Me, Windows 95, 和Windows CE. 在苹果机上,字符串包括版本号,比如Mac OS 9.2.1 或Mac OS X 10.4.4.

你可能基于操作系统做一些特殊处理,比如,根据当前系统载入特定的图标,或只是记录下用户的操作系统来统计。
下面的代码展示检测操作系统:
+展开
-ActionScript
var os:String = System.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
}

加支付宝好友偷能量挖...


评论(0)网络
阅读(108)喜欢(0)flash/flex/fcs/AIR