关于FLEX输出时:IE提示"Alternate HTML content should be placed here. This content requir

最近在用FLEX写东西,运行HTML时候总提示:Alternate HTML content should be placed here. This content requires the Adobe Flash Player,开始以为FLASH版本问题,重新装了几次还是老样子,打开JS文件调试了会,终于知道问题出在哪了。
在生成的JS文件中有段这样的语句:

function ControlVersion()
{
    var version;
    var axo;
    var e;

    // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

    try {
        // version will be set for 7.X or greater players
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        version = axo.GetVariable("$version");
    
    } catch (e) {
    
    }

    if (!version)
    {
        try {
            // version will be set for 6.X players only
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
            
            // installed player is some revision of 6.0
            // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
            // so we have to be careful. 
            
            // default to the first public version
            version = "WIN 6,0,21,0";

            // throws if AllowScripAccess does not exist (introduced in 6.0r47)        
            axo.AllowScriptAccess = "always";

            // safe to call for 6.0r47 or greater
            version = axo.GetVariable("$version");

        } catch (e) {
        }
    }

    if (!version)
    {
        try {
            // version will be set for 4.X or 5.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }

    if (!version)
    {
        try {
            // version will be set for 3.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = "WIN 3,0,18,0";
        } catch (e) {
        }
    }

    if (!version)
    {
        try {
            // version will be set for 2.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11";
        } catch (e) {
            version = -1;
        }
    }
    
    return version;
}

 在IE7中运行这段代码的时候,函数最后会运行到,最后一个if(!verson),此时返回的是WIN 2,0,0,11,之后代码
又截取到版本为2并与你要求的FLASH版本号对比(如9),此时就提示你版本太低,产生这个原因,大约是因为FLASH并没有严格按照COM组件的标准,在获取版本号时产生错误,Firfox下 不会有这样的错误。

解决方法是,使用Firfox调试你的程序,或者修改

if (!version)
    {
        try {
            // version will be set for 2.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11";
        } catch (e) {
            version = -1;
        }
    }

 为

 

if (!version)
    {
        try {
            // version will be set for 2.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version=axo.GetVariable("$version");
        } catch (e) {
            version = "WIN 2,0,0,11";
        }
    }

 这样就可以了,至于其他电脑上的兼容问题,有待进一步的调试。

你可能感兴趣的:(Flex)