Groups | Blog | Home
all groups > flash actionscript > august 2006 >

flash actionscript : XML Loading Problem - Review Code



Steele Imaging
8/13/2006 6:43:36 PM
Here is the structure of my FLA file for this problem:

Screens are as follows:

STEELEIMAGINGLTD_SCR
-HOME_SCR
-CLIENT_SCR
-DEMOS_SCR
-ABOUT_SCR
-CONTACT_SCR
-MENU_SCR

On the initial load, the STEELEIMAGING_SCR contains the follow XML code to
load customer data into the FLA file so that when a client selects "Client
Login" from the menu screen, this data is available to process the login
feature. It DOES work, however, sometimes it takes 4 or 5 refreshed of internet
exlporer to get the code loaded. Once it's loaded, it works like a charm.

[code]

function parseXML(success) {
if (!success)
{
gotoAndPlay("badload");
return;
}
var customers = this.childNodes[0].childNodes;
for (var i = 0; i<customers.length; i++)
{
var custLine = Array();
custLine["compName"] = customers[i].attributes.compName;
custLine["username"] = customers[i].attributes.username;
custLine["subdir"] = customers[i].attributes.subdir;
custLine["clientpage"] = customers[i].attributes.clientpage;
custLine["contact"] = customers[i].attributes.contact;
custLine["clientCategory"] = customers[i].attributes.clientCategory;
custLine["activeContract"] = customers[i].attributes.activeContract;
custLine["contractStart"] = customers[i].attributes.contractStart;
custLine["contractEnd"] = customers[i].attributes.contractEnd;
custLine["contractStatus"] = customers[i].attributes.contractStatus;
custLine["sweeperLimit"] = customers[i].attributes.sweeperLimit;
custLine["sweeperSubLimit"] = customers[i].attributes.sweeperSubLimit;
custLine["promoLimit"] = customers[i].attributes.promoLimit;
custLine["promoSubLimit"] = customers[i].attributes.promoSubLimit;
custLine["pagesLimit"] = customers[i].attributes.pagesLimit;
custLine["clientMessage"] = customers[i].attributes.clientMessage;
_global.customers.push(custLine);
}
}
_global.customers = Array();
cust_xml = new XML();
cust_xml.ignoreWhite = true;
cust_xml.onLoad = parseXML;
cust_xml.load("customer.xml");
stop();

[end]

Why does the XML file not take on the initial load of the SWF in Explorer? Is
the code in the wrong place? Is there an error in this code that I am not aware
of? Does anyone have a suggestion?

[b]I will deposit $25.00 US to the PAYPAL account of the first person to
CORRECTLY solve this issue.[/b]
Thank you.
Dave Steele

kglad
8/13/2006 7:17:19 PM
Steele Imaging
8/13/2006 7:28:52 PM
Ok, how do I do that? I have already added the following to ensure my XML is
refreshed on the browser each time:

id = ((Math.random()*15)+"ie43");//just to keep the xml fresh
cust_xml.load("customer.xml?id="+id)

Now, how do I make sure it's loaded before I let the movie progress?
kglad
8/13/2006 8:13:33 PM
if the only way your project uses the xml data is after ClientLoginBtn is
pressed you could use:





cust_xml = new XML();
cust_xml.ignoreWhite = true;
cust_xml.onLoad = parseXML;
cust_xml.load("customer.xml");
ClientLoginBtn.enabled=0;
preloadI=setInterval(preloadF,100);
stop();

function preloadF(){
bl=cust_xml.getBytesLoaded();
bt=cust_xml.getBytesTotal();
if(bl>0&&bl>=bt){
clearInterval(preloadI);
ClientLoginBtn.enabled=1;
}
}
Steele Imaging
8/13/2006 8:23:51 PM
Cool. I am going to give this a shot. On the FLA file, would I put this code on
the CLIENT_SCR to ensure that the code has loaded? Or, does this somehow fit on
the initial STEELEIMAGINGLTD_SCR?

Let me know what area to put the code....

If this works, have a paypal account so I can send the $$
Steele Imaging
8/18/2006 4:49:22 AM
Go to:

http://www.steeleimaging.com

You will need to click on the client tab and enter the username of: guest

It may take 8 to 10 times when you enter the user name for the SWF file to
"catch" it... if this happens to you, this is the exact problem I am trying to
correct.

Please let me knoe when you have it so I can take it offline. My personal
email is steele@steeleimaging.com

Thanks,
Dave Steele
kglad
8/18/2006 6:00:27 PM
Steele Imaging
8/18/2006 6:07:01 PM
kglad
8/18/2006 6:10:58 PM
kglad
8/18/2006 9:32:40 PM
your edited file that preloads your xml file before enabling your login button
is at:

www.gladstien.com/new/steele imaging - final_2006.zip

i'm unable to test to see if this resolves your issue. but if you test and
find that the login button is not clickable for a while after entering a user
name and that when the button is clickable all works well, you'll probably want
to polish your presentation so user's don't get frustrated trying to click an
unclickable button.

but first see if your issue is resolved.
AddThis Social Bookmark Button