0

I have created a simple flash object to redirect a browser to a different webpage using "navigatetoURL" while getting the URL from externalinterface calls to the javascript that the page doing the embedding of the flash file has.

I am able to build everything just fine and the html page I created (using swfobject.embedSWF to embed the flash file) runs fine and redirects the browser. However when I move the files that are needed for everything to function (the .swf file, swfobject.js, and the html file that embeds the flash object) the webpage does not redirect anymore. Just a blank space, which seems to be the flash object, is displayed and nothing is redirected.

Is there any compile option in Flashdevelop that I'm missing to prevent correct this?

Here is the actionscript 3 code:

package 
{
 import flash.display.Sprite;
 import flash.events.Event;
 import flash.net.navigateToURL;
 import flash.net.URLRequest;
 import flash.net.URLVariables;
 import flash.external.ExternalInterface;

public class FlashTest extends Sprite
{
 public function FlashTest()
 {
    var url:String = ExternalInterface.call("GetURL");
    var hash:String = ExternalInterface.call("GetHash");
    var new_url:String = url + hash;
    var request:URLRequest = new URLRequest(new_url);
    navigateToURL(request, "_self");

 }
}
}

The HTML code:

<html>
<head>

<script src='js/swfobject.js' type='text/javascript'></script>
<script type='text/javascript'>
swfobject.embedSWF('Flashtest.swf', 'altContent', '100%', '100%', '10.0.0');
function GetURL()
{
   return 'http://www.cnn.com';
}

function GetHash()
{
  return '?hash=2398asb9s8234';
}

</script>
</head>
<body>
<div id='altContent'>
<h1>Flash_test</h1>
<p>Alternative content</p>
<p><a href='http://www.adobe.com/go/getflashplayer'><img 
src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' 
alt='Get Adobe Flash player' /></a></p>
</div>
</body>
</html>
4

2 回答 2

0

实际上,在将 swf 添加到 HTML DOM 之前和/或在 DOM 准备好之前,我一直在启动 swf。看看Adob​​e 自己关于 ExternalInterface.call 和 javascript isReady 的文章。我还要看看 allowScriptAccess 参数:

<script type="text/javascript">
   var so = new SWFObject("movie.swf", "mymovie", "400", "200", "8", "#336699");
   so.addVariable("allowScriptAccess", "always");
   so.write("flashcontent");
</script>
于 2010-10-24T22:17:12.863 回答
0

这实际上是一个 Flash 播放器的安全问题。如果您将文件移出 bin 文件夹并在本地运行它们,它们将不再工作。

每次您在 flashdevelop 中创建项目时,都会将“bin”文件夹添加到 flash 播放器的例外列表中。如果您将文件移动到另一个文件夹,那么它们将不再工作,因此在浏览器中打开 html 时会出现空白页面。

解决方法是手动修改flash player安全配置文件并添加新路径或访问: http: //www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html 点击全局安全设置>始终允许 > 编辑位置 > 添加位置 > 浏览文件所在的新路径。

于 2010-12-16T00:10:37.257 回答