开发者

swf will not work on server. Runs fine locally

开发者 https://www.devze.com 2023-03-12 01:10 出处:网络
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

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 any开发者_开发知识库thing? Any help would be greatly appreciated. Many, many thanks in advance.


The problem is, you have wrong urls. The swf searches for your images at

http://www.aaronletourneau.ca/ecometrix/Site/Refresh/img/01.jpg

but they are located in

http://www.aaronletourneau.ca/ecometrix/Site/Refresh/banner/img/01.jpg

You can add this relative path in your xml banner/img/01.jpg as source or have a flashVar 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消