Groups | Blog | Home
all groups > flash data integration > january 2005 >

flash data integration : Loading XML data every 20 seconds


Ken Fine
1/3/2005 11:29:21 AM
Learn,

Please post finished code.

-KF


[quoted text, click to view]

Learn
1/3/2005 2:57:03 PM
Hi all,

My problem is not loading data from an XML file but loading a new childNode
every 20 seconds. What i have at the moment is as included in the code.
Function loadNextSlide() loads all the data in one go and finishes with the
last child's data displayed, but i want it to wait for 20 seconds before it
loads the 2nd childnode, then another 20 secs before the 3rd and so on.

If someone has a solution or has any idea of how i can do this please let me
know,

Gratefully,

Learn......
Nothing's impossible!!


--------------------Code------------------




slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("Portfolio/slides.xml");
slides_xml.ignoreWhite = true;
//
// Show the first slide and intialize variables
function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
_global.totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
loadNextSlide(firstSlideNode);
}
}

function loadNextSlide(firstSlideNode)
{
for( var i:Number = 0; i <= totalSlides; i++)
{
if (i == 1) {updateSlide(firstSlideNode);}
if ((i > 1))//&& (TimeResult >= 20))
{
nextSlideNode = firstSlideNode.nextSibling;
if (nextSlideNode == null)
{
break;
}
else
{
//i++;
updateSlide(nextSlideNode);
firstSlideNode = nextSlideNode;
}
}
}
}

// Updates the current slide with new image and text
function updateSlide(currentSlideNode) {
imagePath = currentSlideNode.attributes.jpegURL;
description = currentSlideNode.attributes.description;
client = currentSlideNode.attributes.client;
technology = currentSlideNode.attributes.technology;
loadMovie(imagePath, targetClip);
}
Learn
1/3/2005 6:23:07 PM
Got the answer!!!

Very simple, just used a counter from the parent movie clip that supplied variable value the XML movie clip.

Learn...
Learn
1/3/2005 10:06:08 PM
Hey!!

I decided to use an alternative solution. i initialised a counter in the main
timeline and increased it everytime the tween on the main timeline had finished
playing.

frame 1: var Count = 1;
frame 2: Start Tween;
frame 150: FINISH TWEEN, CODE FOR THE FRAME:
if (Count < totalSlides)
{Count++;}
else if (Count == totalSlides)
{ Count =1;}
gotoAndPlay(2);

i than used the value for "Count" in my xml movie to display the next
childNode. Not what i posted the question for but it provides the functionality
i needed.

Hope this is OK,

Learn...
Nothing is Impossible.....
morksinaanab
1/5/2005 10:56:53 PM
Note that you can always use the getTimer() function to get the time in
milliseconds from the start of the SWF, to actually time something, instead of
counting frames And you also could use the Date class to get the current
system time.
AddThis Social Bookmark Button