如何检查是否一个SWF正在作为一个AIR应用程序?作为一个、应用程序、SWF、AIR

2023-09-08 13:40:46 作者:迷糊小生

我不知道是否有一种方法为SWF以检查在运行时是否正在运行一个在线的SWF或AIR应用程序?我需要使用相同的SWF运行在线和本地,但作为一个AIR应用程序运行的时候,外部资产位于不同的目录。我想检查的SWF是本地的还是在线这样我就可以改变对外资产相应的源路径。

I'm wondering if there is a way for a SWF to check at runtime whether it is running as an online SWF or an AIR app? I need to use the same SWF to run both online and locally, however when running as an AIR app, external assets are located in a different directory. I'd like to check whether a SWF is local or online so I can change the source path for external assets accordingly.

谢谢, 桑德罗

编辑:我刚刚意识到这可能是一个愚蠢的问题。 :)我可能只是使用Flash变量来告诉它是在一个AIR应用程序运行的SWF。

I just realized this might be a dumb question. :) I may just use flashvars to tell the SWF that it is running within an AIR app.

推荐答案

您可以使用的 Capabilities类。

You can use the Capabilities class.

import flash.system.Capabilities;

switch (Capabilities.playerType) {
    case 'Desktop':
        //air runtime
        break;
    case 'PlugIn':
    case 'ActiveX':
        //browser
        break;
}

这是Adobe的ActionScript 3参考。