swf 无法在服务器上运行。本地运行良好
我有一个横幅 (XML_Banner.swf),它应该从 XML 文件 (banners.xml) 加载和旋转图像。当我在本地预览网站时,没有遇到任何问题。然而,一旦进入 Linux Web 服务器,电影似乎可以加载,但不显示图片。只是一个黑盒子。如果我导航到横幅,它也可以毫无问题地加载。
http://www.aaronletourneau.ca/ecometrix/Site/Refresh/banner /XML_Banner.swf
这可能是一个非常简单的修复,但我一直忽略。以下是一些详细信息:
- 横幅文件位于站点根文件夹内名为“banner”的文件夹中。
- 我已将文件 XML_Banner.swf、XML_Banner.html 和 Banners.xml 放置在文件夹“banner”内。
- 横幅图像位于“banner”内的“img”文件夹中。
- 文件 (AC_RunActiveContent.js) 位于横幅文件夹内名为“Scripts”的文件夹内。
引用文件:
<script type="text/javascript" src="Scripts/AC_RunActiveContent.js"></script>
嵌入代码:
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="878" HEIGHT="220" id="XML_Banner" ALIGN="">
网址: http://www.aaronletourneau.ca/ecometrix/Site/Refresh/index.html
编辑 这是我的 XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<rotator isRandom="false">
<bannerTime>5</bannerTime>
<numberOfBanners>7</numberOfBanners>
<banners showHeader="true">
<banner>
<name>Arrival of Spring.</name>
<body></body>
<imagePath>img/01.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Fishing in Peru.</name>
<body></body>
<imagePath>img/02.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Peruvian Cattle.</name>
<body></body>
<imagePath>img/03.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Shoreline of Port Hawksbury, NS.</name>
<body></body>
<imagePath>img/04.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Lilies afloat.</name>
<body></body>
<imagePath>img/05.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Logging road.</name>
<body></body>
<imagePath>img/06.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Small rapids.</name>
<body></body>
<imagePath>img/07.jpg</imagePath>
<link>gallery.html</link>
</banner>
</banners>
</rotator>
编辑 这是我的 AS:
//Load from XML File
stop();
//Banner
var banners:Array = new Array();
//Image Path
var imagePaths:Array = new Array();
//Link URL
var links:Array = new Array();
//Body Text
var bodyTexts:Array = new Array();
//
var imageTime:Number;
//
var numberOfBanners:Number;
//
var isRandom:String;
//
var showHeader:String;
//
var bannersXML:XML = new XML();
bannersXML.ignoreWhite = true;
bannersXML.load("banner/banners.xml");
bannersXML.onLoad = function(success) {
if (success) {
trace("XML LOADED");
imageTime = parseInt(this.firstChild.firstChild.firstChild)*1000;
numberOfBanners = parseInt(this.firstChild.childNodes[1].firstChild);
isRandom = this.firstChild.attributes["isRandom"];
showHeader = this.firstChild.childNodes[2].attributes["showHeader"];
var bannerSequence:Array = new Array();
if (isRandom == "true") {
//Make a random sequence
while (bannerSequence.length<numberOfBanners) {
newRandomNumber = random(numberOfBanners);
//Make sure that the random one chosen is not already chosen
for (var i = 0; i<=bannerSequence.length; i++) {
if (newRandomNumber != bannerSequence[i]) {
alreadyThere = false;
} else {
alreadyThere = true;
break;
}
}
//Add only random values that aren't in the array
if (!alreadyThere) {
bannerSequence.push(newRandomNumber);
}
}
} else {
for (var i = 0; i<numberOfBanners; i++) {
bannerSequence.push(i);
}
}
}
//Read XML in the Random Order Chosen
for (var i = 0; i<numberOfBanners; i++) {
banners.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].firstChild.firstChild.toString());
bodyTexts.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[1].firstChild.nodeValue);
imagePaths.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[2].firstChild.nodeValue);
links.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[3].firstChild.nodeValue);
}
play();
};
//Start the image counter at 0
var imageCounter = 0;
stop();
//Check to see if the banner should be reset
if (imageCounter>=banners.length) {
imageCounter = 0;
}
//Load banner image
var imageLoader:MovieClipLoader = new MovieClipLoader();
imageLoader.loadClip("banner/img/"+imagePaths[imageCounter],bannerContainer_mc);
var loadingListener:Object = new Object();
loadingListener.onLoadComplete = function() {
play();
//Display Header
if (showHeader == "true") {
imageText_mc.headerTxt.text = banners[imageCounter].toString();
} else {
imageText_mc.headerTxt.text = "";
imageText_mc._alpha = 0;
}
//Button and Link Handling
if (links[imageCounter] != null) {
trace("LINK : "+links[imageCounter]);
bannerContainer_mc.onRelease = function() {
getURL(links[imageCounter], "_self");
};
} else {
delete bannerContainer_mc.onRelease;
}
};
imageLoader.addListener(loadingListener);
有什么不正确的地方还是我遗漏了什么? 任何帮助将不胜感激。非常非常感谢。
I have a banner (XML_Banner.swf) that is supposed to load and rotate images from an XML file (banners.xml). When I preview my the site locally, I get no problems. However, once on the Linux web server the movie seems to load but displays no pictures. Just a black box. If I navigate to the banner it also loads with no problem.
http://www.aaronletourneau.ca/ecometrix/Site/Refresh/banner/XML_Banner.swf
It is probably a very simple fix that I keep overlooking. Here are some details:
- The banner files are located in a folder entitled "banner" inside the root folder for the site.
- I have placed the files XML_Banner.swf, XML_Banner.html, and banners.xml inside the folder "banner".
- Images for the banner are located in a folder "img" inside of "banner".
- The file (AC_RunActiveContent.js) is located inside a folder named "Scripts" inside the banner folder.
Referencing the file:
<script type="text/javascript" src="Scripts/AC_RunActiveContent.js"></script>
Embedding code:
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="878" HEIGHT="220" id="XML_Banner" ALIGN="">
URL:
http://www.aaronletourneau.ca/ecometrix/Site/Refresh/index.html
EDIT
Here is my XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<rotator isRandom="false">
<bannerTime>5</bannerTime>
<numberOfBanners>7</numberOfBanners>
<banners showHeader="true">
<banner>
<name>Arrival of Spring.</name>
<body></body>
<imagePath>img/01.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Fishing in Peru.</name>
<body></body>
<imagePath>img/02.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Peruvian Cattle.</name>
<body></body>
<imagePath>img/03.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Shoreline of Port Hawksbury, NS.</name>
<body></body>
<imagePath>img/04.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Lilies afloat.</name>
<body></body>
<imagePath>img/05.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Logging road.</name>
<body></body>
<imagePath>img/06.jpg</imagePath>
<link>gallery.html</link>
</banner>
<banner>
<name>Small rapids.</name>
<body></body>
<imagePath>img/07.jpg</imagePath>
<link>gallery.html</link>
</banner>
</banners>
</rotator>
EDIT Here is my AS:
//Load from XML File
stop();
//Banner
var banners:Array = new Array();
//Image Path
var imagePaths:Array = new Array();
//Link URL
var links:Array = new Array();
//Body Text
var bodyTexts:Array = new Array();
//
var imageTime:Number;
//
var numberOfBanners:Number;
//
var isRandom:String;
//
var showHeader:String;
//
var bannersXML:XML = new XML();
bannersXML.ignoreWhite = true;
bannersXML.load("banner/banners.xml");
bannersXML.onLoad = function(success) {
if (success) {
trace("XML LOADED");
imageTime = parseInt(this.firstChild.firstChild.firstChild)*1000;
numberOfBanners = parseInt(this.firstChild.childNodes[1].firstChild);
isRandom = this.firstChild.attributes["isRandom"];
showHeader = this.firstChild.childNodes[2].attributes["showHeader"];
var bannerSequence:Array = new Array();
if (isRandom == "true") {
//Make a random sequence
while (bannerSequence.length<numberOfBanners) {
newRandomNumber = random(numberOfBanners);
//Make sure that the random one chosen is not already chosen
for (var i = 0; i<=bannerSequence.length; i++) {
if (newRandomNumber != bannerSequence[i]) {
alreadyThere = false;
} else {
alreadyThere = true;
break;
}
}
//Add only random values that aren't in the array
if (!alreadyThere) {
bannerSequence.push(newRandomNumber);
}
}
} else {
for (var i = 0; i<numberOfBanners; i++) {
bannerSequence.push(i);
}
}
}
//Read XML in the Random Order Chosen
for (var i = 0; i<numberOfBanners; i++) {
banners.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].firstChild.firstChild.toString());
bodyTexts.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[1].firstChild.nodeValue);
imagePaths.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[2].firstChild.nodeValue);
links.push(this.firstChild.childNodes[2].childNodes[bannerSequence[i]].childNodes[3].firstChild.nodeValue);
}
play();
};
//Start the image counter at 0
var imageCounter = 0;
stop();
//Check to see if the banner should be reset
if (imageCounter>=banners.length) {
imageCounter = 0;
}
//Load banner image
var imageLoader:MovieClipLoader = new MovieClipLoader();
imageLoader.loadClip("banner/img/"+imagePaths[imageCounter],bannerContainer_mc);
var loadingListener:Object = new Object();
loadingListener.onLoadComplete = function() {
play();
//Display Header
if (showHeader == "true") {
imageText_mc.headerTxt.text = banners[imageCounter].toString();
} else {
imageText_mc.headerTxt.text = "";
imageText_mc._alpha = 0;
}
//Button and Link Handling
if (links[imageCounter] != null) {
trace("LINK : "+links[imageCounter]);
bannerContainer_mc.onRelease = function() {
getURL(links[imageCounter], "_self");
};
} else {
delete bannerContainer_mc.onRelease;
}
};
imageLoader.addListener(loadingListener);
Is there something incorrect or am I missing anything?
Any help would be greatly appreciated. Many, many thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是,您的网址错误。 swf 搜索您的图像,
但它们位于
您可以在 xml
banner/img/01.jpg
中添加此相对路径作为源,或者使用flashVar
相对路径。您必须修改 AS 代码才能使用此相对路径(如果给定)。swf 从它所包含的 HTML 的基本 url 中获取相对 url,而不是 swf 所在的位置。
The problem is, you have wrong urls. The swf searches for your images at
but they are located in
You can add this relative path in your xml
banner/img/01.jpg
as source or have aflashVar
with that relative path. You have to modify your AS code to use this relative path, if given.The swf takes relative url's from the base url of the HTML it is included, not where the swf resides.