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

flash data integration : Problem with xml loading a second time


ChuckyLeFrek
12/7/2005 12:37:57 PM
Hi there

I am loading in some xml to get the values for a Poll on my site. This works
fine when the page first loads. However after someone has voted in the Poll
I then want to read in the new values from the xml file.

The code I have is as follows:

pollData = new XML();
pollData.ignoreWhite = true;
pollData.load("xml/movies_poll.xml?uniqueID=" + getTimer());



pollData.onLoad = function(success){

trace("XML file loaded");

if(success){
// my code goes in here
} else {
trace("XML file could not be loaded");
}

}

As I said, this works fine when I first load the page.

After a vote I then call the following function

Get_Poll_Data();

i.e

function Get_Poll_Data() {

trace ("Get Poll Data");

//load in XML
pollData = new XML();
pollData.ignoreWhite = true;
pollData.load("xml/movies_poll.xml?uniqueID=" + getTimer());


};

However it is not reloading the xml file again and I have no idea why not.
It does not appear to be calling the .onLoad function the second time

Any help much appreciated.

Thanks

Motion Maker
12/7/2005 11:49:34 PM
Looks like a variable scope problem

You have two pollData variables.

One inside a function that does not have an onLoad handler.

If you do not have too much code when you test movie you might see this with
Debug->List Variables.

Try eliminating the

pollData = new XML();
pollData.ignoreWhite = true;
inside the function. The first line creates a new pollData variable scoped
to inside the function and the second line is unnecessary when you remove
the first.

--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
Hi there

I am loading in some xml to get the values for a Poll on my site. This
works
fine when the page first loads. However after someone has voted in the Poll
I then want to read in the new values from the xml file.

The code I have is as follows:

pollData = new XML();
pollData.ignoreWhite = true;
pollData.load("xml/movies_poll.xml?uniqueID=" + getTimer());



pollData.onLoad = function(success){

trace("XML file loaded");

if(success){
// my code goes in here
} else {
trace("XML file could not be loaded");
}

}

As I said, this works fine when I first load the page.

After a vote I then call the following function

Get_Poll_Data();

i.e

function Get_Poll_Data() {

trace ("Get Poll Data");

//load in XML
pollData = new XML();
pollData.ignoreWhite = true;
pollData.load("xml/movies_poll.xml?uniqueID=" + getTimer());


};

However it is not reloading the xml file again and I have no idea why not.
It does not appear to be calling the .onLoad function the second time

Any help much appreciated.

Thanks

ChuckyLeFrek
12/8/2005 9:19:41 AM
Thanks a million Lon

I had completely overlooked that - doh!

Anyway I will give it a go later this morning when I can get someone to upload the new files to the testing server.

Cheers

Motion Maker
12/8/2005 10:12:18 AM
Now that I think about it I was slightly incorrect. You only have one
pollData variable because there is no var keyword in the function, but the
second construction (instantiation) of the pollData variable I think kills
the pollData.onLoad.

--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
Thanks a million Lon

I had completely overlooked that - doh!

Anyway I will give it a go later this morning when I can get someone to
upload the new files to the testing server.

Cheers

Paul

AddThis Social Bookmark Button