在Adobe Air中获取当前操作系统

时间:2021-10-09 03:36:25

I'm making an App using Adobe Flex/Air. I was wondering if there is any way to get the Operating System the Air app is running on?

我正在使用Adobe Flex / Air制作应用程序。我想知道是否有办法让Air应用程序运行的操作系统?

3 个解决方案

#1


Use Capabilities class:

使用功能类:

import flash.system.Capabilities;

trace(Capabilities.os);

#2


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
 }

#3


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

为清楚起见,我使用这段代码(虽然它与Mudasir的相同)

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

flash.system.Capabilities.os():String [只读]​​指定当前操作系统。 os属性可以返回以下字符串:操作系统值

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"

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 XYZ“(其中XYZ是版本号,例如:”Mac OS 10.5.2“)Linux”Linux“(Flash Player附带Linux版本,例如”Linux 2.6.15-1.2054_FC5smp“iPhone OS 4.1” iPhone3,1"

The server string is OS.

服务器字符串是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.

如果存在更具体的功能属性,请不要使用Capabilities.os来确定基于操作系统的功能。基于操作系统的功能是一个坏主意,因为如果应用程序不考虑所有潜在的目标操作系统,它可能会导致问题。而是使用与您要测试的功能相对应的属性。有关更多信息,请参阅Capabilities类描述。

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

语言版本:3.0播放器版本:Flash 9,AIR 1.0,Lite 4

#1


Use Capabilities class:

使用功能类:

import flash.system.Capabilities;

trace(Capabilities.os);

#2


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
 }

#3


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

为清楚起见,我使用这段代码(虽然它与Mudasir的相同)

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

flash.system.Capabilities.os():String [只读]​​指定当前操作系统。 os属性可以返回以下字符串:操作系统值

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"

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 XYZ“(其中XYZ是版本号,例如:”Mac OS 10.5.2“)Linux”Linux“(Flash Player附带Linux版本,例如”Linux 2.6.15-1.2054_FC5smp“iPhone OS 4.1” iPhone3,1"

The server string is OS.

服务器字符串是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.

如果存在更具体的功能属性,请不要使用Capabilities.os来确定基于操作系统的功能。基于操作系统的功能是一个坏主意,因为如果应用程序不考虑所有潜在的目标操作系统,它可能会导致问题。而是使用与您要测试的功能相对应的属性。有关更多信息,请参阅Capabilities类描述。

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

语言版本:3.0播放器版本:Flash 9,AIR 1.0,Lite 4