4

我有一个由 EasyPano tourweaver 软件创建的 swf 文件。输出是一个带有一些 .bin 文件的 swf 文件,用于配置 swf 和其他文件,例如 .jpg、.js 等。该软件创建一个 html 文件来添加 swf,但我必须使用 flash 和 AS3 加载 swf。该软件创建的 HTML 和 JavaScript 是:

 <html> 
 <head> 
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
 <title>Mahan</title> 
 </head> 
 <body leftMargin="0" topMargin="0" rightMargin="0" bottomMargin="0"> 
 <script type="text/javascript" src="swfobject.js"></script> 
 <div id="flashcontent"> 
 To view virtual tour properly, Flash Player 9.0.28 or later version is needed. 
 Please download the latest version of <a href="http://www.adobe.com/go/getflashplayer" target="_blank">Flash Player</a> and install it on your computer.
 </div> 

 <script type="text/javascript"> 
 // <![CDATA[ 
 var so = new SWFObject("twviewer.swf", "sotester", "100%", "100%", "9.0.0", "#000000"); 
 so.addParam("allowNetworking", "all"); 
 so.addParam("allowScriptAccess", "always"); 
 so.addParam("allowFullScreen", "true"); 
 so.addParam("scale", "noscale"); 
 //<!-%% Share Mode %%->
 so.addVariable("lwImg", "resources/talarmahan_1_firstpage.jpg"); 
 so.addVariable("lwBgColor", "255,255,255,255"); 
 so.addVariable("lwBarBgColor", "255,232,232,232"); 
 so.addVariable("lwBarColor", "255,153,102,153"); 
 so.addVariable("lwBarBounds", "-156,172,304,8"); 
 so.addVariable("lwlocation", "4"); 
 so.addVariable("lwShowLoadingPercent", "false"); 
 so.addVariable("lwTextColor", "255,0,0,204"); 
 so.addVariable("iniFile", "config_TalarMahan.bin"); 
 so.addVariable("progressType", "0"); 
 so.addVariable("swfFile", ""); 
 so.addVariable("href", location.href); 
 so.write("flashcontent"); 
 // ]]> 
 </script> 
 </body> 
 </html>

请帮我!

谢谢

4

1 回答 1

2

答案是将 URLVariables 传递给 URLRequest 提要到 Loader 的 load 方法中:)

例子:

        var loader:Loader = new Loader();
        var flashvars:URLVariables = new URLVariables()
            flashvars["lwImg"] = "resources/talarmahan_1_firstpage.jpg";
            flashvars["lwBgColor"] = "255,255,255,255";
            flashvars["lwBarBgColor"] = "255,232,232,232";
            flashvars["lwBarColor"] = "255,153,102,153";
            flashvars["lwBarBounds"] = "-156,172,304,8";
            flashvars["lwlocation"] = "4";
            flashvars["lwShowLoadingPercent"] = "false";
            flashvars["lwTextColor"] = "255,0,0,204";
            flashvars["iniFile"] = "config_TalarMahan.bin";
            flashvars["progressType"] = "0";
            flashvars["swfFile"] = "";
            flashvars["href"] = this.loaderInfo.url;
        var request:URLRequest = new URLRequest("twviewer.swf");
            request.data = flashvars;
        loader.load(request);

        addChild(loader);

还可以使用以下辅助方法获取主要 SWF 参数(来自它的 html 包装器)并将其传递给加载的 SWF:

    public function getFlashVars(li:LoaderInfo):URLVariables
    {
        var vars:URLVariables = new URLVariables();
        try
        {
            var params:Object = li.parameters;
            var key:String;
            for(key in params)
            {
                vars[key] = String(params[key]);
            }
        }
        catch(e:Error)
        {
        }
        return vars;
    }

然后

        var loader:Loader = new Loader();
        var request:URLRequest = new URLRequest("twviewer.swf");
            request.data = getFlashVars(this.loaderInfo);
        loader.load(request);

        addChild(loader);

对于SecurityError: Error#2000这里- 这个错误背后有很多原因

于 2012-11-06T07:11:00.823 回答