我有一个横幅(XML_Banner.swf),它应该从XML文件(banners.xml)加载和旋转图像。当我在本地预览我的网站时,我没有遇到任何问题。但是,一旦在Linux Web服务器上,电影似乎加载但没有显示图片。只是一个黑盒子。如果我导航到横幅,它也会毫无问题地加载。
http://www.aaronletourneau.ca/ecometrix/Site/Refresh/banner/XML_Banner.swf
这可能是一个非常简单的修复,我一直在忽视。以下是一些细节:
引用文件:
<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="">
URL: 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);
是否有不正确的东西或我遗漏了什么? 任何帮助将不胜感激。很多,非常感谢提前。
答案 0 :(得分:0)
问题是,你的网址有误。瑞士法郎在
搜索您的图片http://www.aaronletourneau.ca/ecometrix/Site/Refresh/img/01.jpg
但它们位于
http://www.aaronletourneau.ca/ecometrix/Site/Refresh/banner/img/01.jpg
您可以在xml banner/img/01.jpg
中添加此相对路径作为源,或者使用该相对路径flashVar
。如果给定,则必须修改AS代码以使用此相对路径。
swf从包含它的HTML的基本URL获取相对url,而不是swf所在的位置。