A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: XML Slideshow - Not updating with XML.

  1. #1
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315

    XML Slideshow Not AUTOMATICALLY with XML change. Help!!!

    This may seem simple, but I'm having a hard time getting this XML slideshow to auto-update when the XML is changed. Any ideas? Am I missing something? I've tried the time stamps like the following, with no success...

    xmlData.load("swfs.xml?vers="+new Date().getTime());

    Here's a link to download the entire package:
    http://www.brianmichaelis.com/xml_slideshow.zip (772kb)

    Getting this to auto-update would be much appreciated!

    If you don't want to download the package, here's the grunt of the AS:

    PHP Code:

    #include "mc_tween2.as"
    Stage.scaleMode "noscale";

    ///////////////////////////////////////
    next_btn._alpha 50;
    prev_btn._alpha 50;
    play_btn._alpha 50;
    stop_btn._alpha 50;

    // Fade functions
    function fadeIn(){
    container._alpha 0;
    container.alphaTo(100,3,"easeOutExpo");
    }
    function 
    fadeOut(){
    container.alphaTo(0,3,"easeOutExpo");
    }

    // Load XML
    function loadXML(loaded) {
        if (
    loaded) {
            
    xmlNode this.firstChild;
            
    swiff = [];
            
    total xmlNode.childNodes.length;
            for (
    i=0i<totali++) {
                
    swiff[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
            }
            
    firstswiff();
            } 
        else {
            
    content "ERROR: Not loaded!";
        }
    }
    xmlData = new XML();
    xmlData.ignoreWhite true;
    xmlData.onLoad loadXML;
    xmlData.load("swfs.xml?vers="+new Date().getTime());
    // End of xml

    //myxml.load("my.xml?vers="+new Date().getTime());

    my_loader = new MovieClipLoader();
    my_loader.addListener(this);
    function 
    onLoadInit(mc:MovieClip) {
        
    preloader._visible false;
    }
    function 
    onLoadProgress(containerbLbT){
        
    perc Math.round((bL/bT)*100);
        
    preloader._visible true;
    }
    var 
    k:Number 0;

    function 
    firstswiff(){
        
    my_loader.loadClip(swiff[k], container);
        
    fadeIn();
    }

    // External swf files call this function 
    // Call function AScode:    _root.nextswf();
    function nextswf(){
        
    k++;
        
    fadeIn();
        if(
    total-1){
            
    k=0
            fadeIn
    ();
            
    my_loader.loadClip(swiff[k], container);
        }
        
    fadeIn();
        
    my_loader.loadClip(swiff[k], container);
    }

    ////////// actions to buttons - functions


    function prevswf(){
        
    k--;
        
    fadeIn();
        if(
    total-3){
            
    k=2
            fadeIn
    ();
            
    my_loader.loadClip(swiff[k], container);
        }
        
    fadeIn();
        
    my_loader.loadClip(swiff[k], container);
    }

    function 
    stopswf(){
        
    container.stop();
    }

    function 
    playswf(){
        
    container.play();
    }

    ///////////////////
    /// Next button ///
    ///////////////////
    next_btn.onRollOver =  function(){
        
    this.alphaTo(100,1,"easeOutExpo");
    }

    next_btn.onRollOut =  function(){
        
    this.alphaTo(50,1,"easeOutExpo");
    }

    next_btn.onRelease next_btn.onReleaseOutside =  function(){
        
    nextswf();
    }


    ///////////////////////
    /// Previous button ///
    ///////////////////////
    prev_btn.onRollOver =  function(){
        
    this.alphaTo(100,1,"easeOutExpo");
    }

    prev_btn.onRollOut =  function(){
        
    this.alphaTo(50,1,"easeOutExpo");
    }

    prev_btn.onRelease prev_btn.onReleaseOutside = function(){
        
    prevswf();
    }


    ///////////////////
    /// Stop button ///
    ///////////////////
    stop_btn.onRollOver =  function(){
        
    this.alphaTo(100,1,"easeOutExpo");
    }

    stop_btn.onRollOut =  function(){
        
    this.alphaTo(50,1,"easeOutExpo");
    }

    stop_btn.onRelease stop_btn.onReleaseOutside = function(){
        
    stopswf();
    }


    ///////////////////
    /// Play button ///
    ///////////////////
    play_btn.onRollOver =  function(){
        
    this.alphaTo(100,1,"easeOutExpo");
    }

    play_btn.onRollOut =  function(){
        
    this.alphaTo(50,1,"easeOutExpo");
    }

    play_btn.onRelease play_btn.onReleaseOutside = function(){
        
    playswf();

    Last edited by intromo; 05-13-2009 at 07:51 PM. Reason: Not yet resolved.

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    are you testing with the xml file online ?
    appended variables (time stamp) will fail if testing off HD

    upload swfs.xml and test with -
    xmlData.load("http://www.domain/swfs.xml?vers="+new Date().getTime());

  3. #3
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Yes - I just tested this online, with no success. Updating the XML and loading it to the server, doesn't change the swf withing the container automatically. When I refresh the HTML - then it updates....

    Any thoughts?

  4. #4
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Ok - I've found a temporary solution to this problem. I'm basically looping the 'container' - with a blank frame at the begining the timeline (which unloads the swf and reloads it, after looking at the updated XML. This created a small glitch, so I duplicated the the 'container2' and put the blank frame at the end of the timeline. Seems to work seemlessly, however there must be a 'cleaner' work around for this? Ideas?

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    have a look in the Help files at setInterval
    place your xml load in a function. call the function with setInterval

    loadInt = setInterval(xmlLoad, 5000); // 1000 msecs = 1 second

  6. #6
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Quote Originally Posted by a_modified_dog View Post
    have a look in the Help files at setInterval
    place your xml load in a function. call the function with setInterval

    loadInt = setInterval(xmlLoad, 5000); // 1000 msecs = 1 second
    Found some information here:
    http://www.kirupa.com/developer/mx20...slideshow3.htm

    However, I'm not sure were to place the setInterval in my code? I need the swfs to update immediately when the XML changes.

    Thanks for your help in advance.

  7. #7
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Quote Originally Posted by a_modified_dog View Post
    have a look in the Help files at setInterval
    place your xml load in a function. call the function with setInterval

    loadInt = setInterval(xmlLoad, 5000); // 1000 msecs = 1 second
    I still can't seem to get this working. This should be a simple... update the XML and the swf immediately changes.

    I think the real problem, is that I can't get the current SWF to unload after an XML change...

    Any ideas? I'm totally burnt trying to look for a solution to this.


  8. #8
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    i'm really not sure where your problem lies


    the only online file i have that might be close to where you are heading is this
    http://www.jackleaman.co.uk/test/xml...hp_to_xml.html

    hope it helps ??

  9. #9
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Quote Originally Posted by a_modified_dog View Post
    i'm really not sure where your problem lies


    the only online file i have that might be close to where you are heading is this
    http://www.jackleaman.co.uk/test/xml...hp_to_xml.html

    hope it helps ??
    Thanks for the link, however it's not exactly what I'm looking for. For example (and maybe to clarify things):

    XML is running this:

    PHP Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <swf>
        <swiff>
            <id>swf1.swf</id>
        </swiff>
    </swf>
    And I update to this:

    PHP Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <swf>
        <swiff>
            <id>swf2.swf</id>
        </swiff>
    </swf>
    I would like the current (swf1.swf) to update immediatly to (swf2.swf). The problem I'm having is that it just keeps playing (swf1.swf). It doesn't unload it on the xml update.

    You see?

  10. #10
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    i have tested this offline, when i change the content of the xml file (as per your above post) the main file loads the new swf file to movieclip- container.
    can you make use of the method ?

    PHP Code:
    loadInt setInterval(xmlLoad5000); 

    function 
    xmlLoad(){
    xmlData = new XML(); 
    xmlData.ignoreWhite true
    xmlData.onLoad loadSWF
    xmlData.load("swiff.xml"); 
    };

    function 
    loadSWF(){
    toLoad this.firstChild.firstChild.firstChild.childNodes;
    container.loadMovie(toLoad);
    }; 

  11. #11
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Quote Originally Posted by a_modified_dog View Post
    i have tested this offline, when i change the content of the xml file (as per your above post) the main file loads the new swf file to movieclip- container.
    can you make use of the method ?

    PHP Code:
    loadInt setInterval(xmlLoad5000); 

    function 
    xmlLoad(){
    xmlData = new XML(); 
    xmlData.ignoreWhite true
    xmlData.onLoad loadSWF
    xmlData.load("swiff.xml"); 
    };

    function 
    loadSWF(){
    toLoad this.firstChild.firstChild.firstChild.childNodes;
    container.loadMovie(toLoad);
    }; 
    Sorry for the slow response here. Was tied down with some other projects. This method DOES work, however I get a 'flicker' everytime the SWF reloads. I'm trying to make this a seamless as possible. Is there anyway to update the xml, and replace the SWF without the flicker?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center