我创建了一个简单的flash对象,使用"navigatetoURL“将浏览器重定向到不同的网页,同时从外部接口调用中获取指向嵌入flash文件的页面的javascript。
我能够很好地构建一切,并且我创建的html页面(使用swfobject.embedSWF嵌入flash文件)运行良好,并重定向浏览器。但是,当我移动所有功能所需的文件( .swf文件、swfobject.js和嵌入flash对象的html文件)时,网页不再重定向。只显示一个似乎是flash对象的空白区域,并且不重定向任何内容。
在Flashdevelop中有没有什么编译选项是我遗漏的,以防止纠正这个错误?
下面是actionscript 3代码:
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");
}
}
}HTML代码:
<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>发布于 2010-10-25 06:17:13
实际上,在swf添加到HTML DOM之前和/或在DOM准备好之前,我就遇到了启动swf的麻烦。看看Adobes own article on ExternalInterface.call and 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-12-16 08:10:37
这实际上是一个flash播放器的安全问题。如果您将这些文件移出bin文件夹并在本地运行它们,它们将不再起作用。
每次你在flashdevelop中创建一个项目时,"bin“文件夹都会被添加到flash播放器的异常列表中。如果你将文件移动到另一个文件夹,那么它们将不再工作,因此在浏览器中打开html时会出现空白页面。
解决方案是手动修改flash player安全配置文件并添加新路径或访问:http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html单击全局安全设置>始终允许>编辑位置>添加位置>浏览文件所在的新路径。
https://stackoverflow.com/questions/3963200
复制相似问题