AS3 嵌套 swf 不显示在 html 中
我使用以下 AS3 代码将外部 swf(尺寸我不喜欢的)加载到另一个 swf 中。当我在嵌入 html 页面时查看加载器 swf 时,即使加载器 swf 在预览中没有问题地显示嵌套的 swf,也不会显示任何内容。
package
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.events.Event;
public class Main extends MovieClip
{
private var swfLoader:Loader;
public function Main()
{
swfLoader = new Loader();
swfLoader.load(new URLRequest("nested.swf"));
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
}
private function loadComplete(e:Event)
{
addChild(swfLoader);
}
}
}
这是我正在使用的 HTML:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<link href="../includes/samplestyle.css" rel="stylesheet" type="text/css"/>
<script src="../Scripts/swfobject_modified.js" type="text/javascript"></script>
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="../includes/AC_RunActiveContent.js" language="javascript"></script>
</head>
<body style="background-color: transparent;">
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '320',
'height', '240',
'src', 'includes/loaderSwf',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'transparent',
'devicefont', 'false',
'id', 'includes/loaderSwf',
'bgcolor', '#ffffff',
'name', 'includes/loaderSwf',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', '../includes/loaderSwf',
'salign', ''
); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="320" height="240" id="includes/loaderSwf" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="../includes/loaderSwf.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="../includes/loaderSwf.swf" quality="high" bgcolor="#ffffff" width="320" height="240" name="includes/loaderSwf" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</noscript>
</body>
</html>
如果我用嵌套的 swf 名称替换名称“loaderSwf”,它就可以正常播放。本地 html 页面似乎不喜欢我通过另一个 swf 播放一个 swf 的事实。有人有这方面的内情吗?
I'm using the following AS3 code to load an external swf (one with dimensions I don't like) into another swf. When I view the loader swf while embedded in a html page nothing is displayed even though the loader swf displays the nested swf without a problem in preview.
package
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.events.Event;
public class Main extends MovieClip
{
private var swfLoader:Loader;
public function Main()
{
swfLoader = new Loader();
swfLoader.load(new URLRequest("nested.swf"));
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
}
private function loadComplete(e:Event)
{
addChild(swfLoader);
}
}
}
And here's the HTML I'm using:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<link href="../includes/samplestyle.css" rel="stylesheet" type="text/css"/>
<script src="../Scripts/swfobject_modified.js" type="text/javascript"></script>
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="../includes/AC_RunActiveContent.js" language="javascript"></script>
</head>
<body style="background-color: transparent;">
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '320',
'height', '240',
'src', 'includes/loaderSwf',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'transparent',
'devicefont', 'false',
'id', 'includes/loaderSwf',
'bgcolor', '#ffffff',
'name', 'includes/loaderSwf',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', '../includes/loaderSwf',
'salign', ''
); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="320" height="240" id="includes/loaderSwf" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="../includes/loaderSwf.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="../includes/loaderSwf.swf" quality="high" bgcolor="#ffffff" width="320" height="240" name="includes/loaderSwf" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</noscript>
</body>
</html>
If I substitute the name "loaderSwf" with the nested swf name it plays fine. It seems as though the local html page does not like the fact that I'm playing a swf through another swf. Does anybody have any inside on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您的 loaderSwf 和 Nested.swf 与您的 html 文件不在同一位置。尝试执行
swfLoader.load(new URLRequest("includes/nested.swf"));
或swfLoader.load(new URLRequest("../includes/nested.swf"));
,取决于您的文件结构的外观。显示 swfLoader 引发的加载错误消息也可能很有用。
It looks like your loaderSwf and nested.swf is not located in the same place as your html-file. Try doing
swfLoader.load(new URLRequest("includes/nested.swf"));
orswfLoader.load(new URLRequest("../includes/nested.swf"));
, depending on how your file structure looks.It might also be useful to display the loading error message that is thrown from the swfLoader.