PDA

View Full Version : Preloader for data?


mcmcom
08-24-2004, 07:53 PM
Hi Guys,


Quick question. I have two simple functions that return values from my server via a perl script. they basically go like this:

_root.remoteService.getCustList();
_root.remoteService.getDealerList();

then I have these functions to retrieve the vals:
(PS Thanks tg and CyanBlue for the multi-dim array help :p)

function getDealerList_Result(rvalue)
{
_global.dlrArray = new Array();
for(var i=0; i < rvalue.length -1; i=i+2) {
_global.dlrArray.push({label:rvalue[i], data:rvalue[i+1]});
}
}

the custList return function is the exact same.

Anyways, these run at the very top of frame 1, right after my netservices code. Sometimes though, they dont load. They are to populate a combobox so sometimes the combobox does not have the data in it because for some reason the service either fails silently, or just never gets called at all! I was wondering if I could make a pre-loader scene that will ensure that the application does not even continue if the arrays are not populated from the perl script. If this is possible to do, how can i make a preloader that will gague the amount of data that has come into flash?

THANKS
MCM

wu-tang
08-24-2004, 08:46 PM
Well i guess my question is how are you loading the Data from the perl script?

A good bet is to use the onLoad event. Here is a sample function that uses the onLoad:


function sendEmail(){

var emailer = new LoadVars();

emailer.specific = "whatever";
emailer.category = "whatever";

emailer.sendAndLoad("email.php", emailer, "POST");

emailer.onLoad = function(){
if(this.error == "invalid"){
erMess.gotoAndStop("email");
} else if(this.error == "later"){
erMess.gotoAndStop("later");
} else {
erMess.gotoAndStop("thanks");
}
}
}


By using a method like this you can wait for the data to arrive before moving into your movie.

Also try running your functions one at a time. first _root.remoteService.getCustList(); then _root.remoteService.getDealerList();
This way you can ensure one is 100% complete before you start the next. I have often found that downloading too much data at once can make flash flakey.

tg
08-24-2004, 09:12 PM
i know squat about flash remoting.... that said. is there a way to check that you have a connection established before executing your remoteservice functions.... maybe they are bombing out sometimes because of a connection problem.

mcmcom
08-24-2004, 09:38 PM
yes i am gonna look into that. Sometimes it just doesn't load...I am unsure if it is our connection (because we host our own sites) but sometimes the script does not activate. What i did for now (just starting), is made a preLoader scene. In that scene I placed one text box (kinda like a status text) and I took my functions to get my data and put them into frame 1 of the preLoader scene. At different points in the functions the status box text changes. Then once its all done (both functions) it moves to the new form. That works fine for now. Gotta pretty it up though :(

Thanks.

PS

I have UNBOUND text fields that a user enters information into. They are HELLA slow!
I mean I can type "The" and have to wait almost two seconds for the word to appear in the text box. They are not databound, and are just typical flash input text. Any ideas as to why they are so slow?

THANKS
Have a good night guys im OFF for the day!

MCM