A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: XML and External SWFs

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    10

    XML and External SWFs

    I am trying to figure out how to read an XML file containing a list of the swfs I want to import, pause for 8 seconds to allow the swf to run and then continue the loop with the next swf.

    I am reading the XML correctly but I am having an issue creating the timer to pause the for loop for 8 seconds between slide.

    -Chris

  2. #2
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    How are u pausing the loop ?
    As ever,
    Vinayak Kadam

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    10
    Vinayak-

    setInterval(pauseLoop(), 8000);

    With pauseLoop being a function currently tracing a piece of text so I know it has hit the function. The traceloop is activate but there is no pause occuring. I have tried it without the parens "()" but setInterval doesn't seem to function without them.

  4. #4
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Can we have ur source files/FLA so that we can check and diagnose the issue much better.
    Last edited by vinayak.kadam; 07-13-2010 at 12:09 AM. Reason: typo!!!!
    As ever,
    Vinayak Kadam

  5. #5
    Junior Member
    Join Date
    Jan 2010
    Posts
    10
    Vinayak-

    Thanks for your thoughts on this, I figured a way to make the script function the way I needed to (see below) although it isn't 100% the best way. The best way would be to start loading the follow-up swf as the first one plays. Once the one on top is done playing, the followup would play while loading the next one in the background.

    My current method simply waits for 11 seconds and begins to load and play the next swf. Works fine for most fast connections, but a slower connection would break I am sure.

    Code:
    stop();
    
    import mx.utils.Delegate;
    
    // declare a new XML instance
    var slides_xml:XML = new XML();
    _global.i = 1;
    
    function pauseLoop (family) {;
    	loadMovie(family.childNodes[i].childNodes[0], "_level10");
    	i++;
    	if (i > slides.length-1) {
    		clearInterval(timer);}
    }
    
    function onXmlLoaded(success:Boolean) {
    	if (success) {
    		var family = slides_xml.firstChild;
    		_global.slides = family.childNodes;
    		loadMovie(family.childNodes[0].childNodes[0], "_level10");
    		_global.timer = setInterval(pauseLoop, 11000, family);
       } else {
          	trace('error reading XML');
       }
    }
    
    function init() {
       // ignore tabs, returns, and other whitespace between nodes
       slides_xml.ignoreWhite = true;
       // set the scope of the onLoad function to the main timeline, not peoplexml
       slides_xml.onLoad = Delegate.create(this, onXmlLoaded);
       // start loading the file
       slides_xml.load("fluid.xml");	   
    }
    
    init();

Tags for this Thread

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