Get Current Operating System In Adobe Air

♀尐吖头ヾ 提交于 2019-12-02 22:00:47

Use Capabilities class:

import flash.system.Capabilities;

trace(Capabilities.os);
if((Capabilities.os.indexOf("Windows") >= 0))
{
     // in windows
}
else if((Capabilities.os.indexOf("Mac") >= 0))
{
// in mac
 } 
 else if((Capabilities.os.indexOf("Linux") >= 0))
 {
// in linux
 }

For clarity sake, I use this code (although it does the same thing as Mudasir's)

if(Capabilities.os.search("Windows")>=0)
     //do something

Here are what the docs say:

flash.system.Capabilities.os():String [Read Only] Specifies the current operating system. The os property can return the following strings: Operating system Value

Windows 7
Windows Vista
Windows Server 2008 R2
Windows Server 2008
Windows Home Server
Windows Server 2003 R2
Windows Server 2003
Windows Server XP 64
Windows XP
Windows 98
Windows 95
Windows NT
Windows 2000
Windows ME
Windows CE
Windows SmartPhone
Windows PocketPC
Windows CEPC
Windows Mobile
Mac OS "Mac OS X.Y.Z" (where X.Y.Z is the version number, for example: "Mac OS 10.5.2")
Linux "Linux" (Flash Player attaches the Linux version, such as "Linux 2.6.15-1.2054_FC5smp"
iPhone OS 4.1 "iPhone3,1"

The server string is OS.

Do not use Capabilities.os to determine a capability based on the operating system if a more specific capability property exists. Basing a capability on the operating system is a bad idea, since it can lead to problems if an application does not consider all potential target operating systems. Instead, use the property corresponding to the capability for which you are testing. For more information, see the Capabilities class description.

Language Version: 3.0 Player Version: Flash 9, AIR 1.0, Lite 4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!