PDA

View Full Version : sendAndLoad problems


Dave's not here
12-19-2005, 06:46 PM
I'm having problems with sendAndLoad not working as expected regularly. Everything works fine when I'm on the server 100% of the time, but when I try to run things, frequently (more than 50% of the time) I don't get my data back and SUCCESS fails, resulting in "weight failed" message. This is going to run as a Projector on a LAN, not from a webpage.

Am I doing something stupid? I thought sendAndLoad waited for a return. Can I adjust the timeout on sendAndLoad?

Offending code:

////////////////////// weight drop down ////////////////////////
// Create Listener Object.
var weightListener:Object = new Object();
// Assign function to Listener Object.
weightListener.close = function(event_obj:Object) {
lengthsGrid.gotoAndStop(1);
mySell.gotoAndStop(1);
weightIn.returnVal = '';
weightIn.locations = '';
weightOut.profile = '';
weightOut.weight = '';
myWeight = event_obj.target.selectedItem.label;
feedback.text = myShape+mySection+"x"+myWeight;
product.text = myShape+mySection+"x"+myWeight;
fubar = myShape+mySection+"x"+myWeight;
weight._alpha = 100;
for (x=0; x<material[feedback.text].length; x++) {
section.addItemAt(x, material[feedback.text][x]);
}
weightOut.profile = myShape+mySection;
weightOut.weight = myWeight;
weightOut.submit = "weight";
weightOut.sendAndLoad("http://192.168.0.3/myData.php", weightIn, "GET");
//get results returned
weightIn.onLoad = function(success) {
if (success) {
////////////// populate inventory ///////////////
myFoo = weightIn.returnval;
myBar = weightIn.locations;
_global.prodID = weightIn.id;
feedback.text = myBar;
lbs = myBar.split("\n");

if (!(Number(weightIn.returnval))) {
lengthsGrid.error.text = myFoo;
}

for (var i = 0; i<(lbs.length-1); i++) {
myLoc = lbs[i].split(":");
//trace("=>"+myLoc[0]+" : i="+i);
}
} else {
//or notify of failure
feedback.text = "weight failed";
}
lengthsGrid.gotoAndStop(5);
};
};
// Add Listeners.
shape.addEventListener("close", shapeListener);
section.addEventListener("close", sectionListener);
weight.addEventListener("close", weightListener);

Cota
12-19-2005, 06:58 PM
If weight failed is being triggered, than the php file isnt being processed. Usually means it isnt running the PHP file for some reason.

falltimemusic
12-19-2005, 07:02 PM
cota is right

its like this


weightIn.onLoad = function(success)
{
if (success)
{
//script file (php, asp, etc..) found, but could still have errors
}
else
{
//script file not found or not running on server.
}
}

Dave's not here
12-19-2005, 07:27 PM
OK, I can confirm that. I added a logfile to the php, and it only wrote 2 for 7 tries. Also, if I hit the php file thru a web browser (on the same remote machine), it works 100%. So, the php file works properly when it is called.

Is there something weird in my AS that would cause it to not make the php call? This is the only thing running on the machine, there's no siginificant load on the server, and we're on a 100MB network with only 8 machines total, so I don't think it's a network issue.

falltimemusic
12-19-2005, 07:50 PM
wheres the line of code where you sendAndLoad() for the php file?

Dave's not here
12-19-2005, 08:04 PM
It's about half way down the original post:

weightOut.sendAndLoad("http://192.168.0.3/myData.php", weightIn, "GET");
//get results returned


Again, it works fine on the server, and the php file fires 100% when I call it directly from a web browser http://92.168.0.3/myData.php?submit=weight&profile=HP14&section=102

Will POST increase reliability? I don't see GET as an issue since all data will be fewer than 256 characters. I've been using GET to ease debugging.

Cota
12-19-2005, 08:08 PM
I generally use POST for everything, but then again I'm a creature of habit. So when you run it locally, it only fires 2 out 7 times or so...?

Dave's not here
12-19-2005, 08:36 PM
On the server (localhost - it's only a test server), it works 100% of the time either using the flash projector or directly calling the php file from a browser's URL.

On a machine on the LAN, it works 100% from the browser URL, but only occasionally works from within flash. Somewhere between 20% to 50% success. It seems to work in spurts, but speed of selecting from the comboBox does *not* appear to have a significant effect on success -- long pauses seem to fail as often as quick succession. Other comboBoxes work consistently. I've tried using the same LoadVar as the others. I've also tried retyping in the code. Neither has helped.

Cota
12-19-2005, 08:39 PM
Yeah um...have you tried kicking it?
Seriously, that doesnt make any sense...it works fine except on the LAN, where it works with crap success...if it were a domain issue it wouldnt work at all, this is really odd.....

Dave's not here
12-19-2005, 09:04 PM
It's been driving me nuts. I keep coming back to it to see if a few days on other parts of the project gives me a new insight, but nothing.

Are there any issues with using OS X 10.3.x and Mac Projectors? I'm not aware of any, but that's about the only thing I can think of. Would .SWF be more reliable than a projector? Can I modify the timeout on the sendAndLoad? Would separate send and load be the way to go? I'm really stumped here.

Dave's not here
12-19-2005, 09:17 PM
Now this is really weird. I moved some of the housekeeping and feedback code to after the sendAndLoad, and now things seem to be working fine (35 for 35 tries on two different machines). What would that change? As odd as it sounds, it appears that too much stuff before the sendAndLoad was causing problems. I know that doesn't make sense, sendAndLoad should take longer than moving playback heads on other movies and writing text,but I didn't do anything else. Really, none of that *should* matter. Anybody with a brilliant explaination?

Now the code looks like:

////////////////////// weight drop down ////////////////////////
// Create Listener Object.
var weightListener:Object = new Object();
// Assign function to Listener Object.
weightListener.close = function(event_obj:Object) {
weightIn.returnVal = '';
weightIn.locations = '';
weightOut.profile = '';
weightOut.weight = '';
myWeight = event_obj.target.selectedItem.label;
weightOut.profile = myShape+mySection;
weightOut.weight = myWeight;
weightOut.submit = "weight";
weightOut.sendAndLoad("http://192.168.0.3/myData.php", weightIn, "GET");
//get results returned to lvIn
weightIn.onLoad = function(success) {
if (success) {
////////////// populate inventory ///////////////
myFoo = weightIn.returnval;
myBar = weightIn.locations;
_global.prodID = weightIn.id;
feedback.text = myBar;
lbs = myBar.split("\n");
if (!(Number(weightIn.returnval))) {
lengthsGrid.error.text = myFoo;
}
//lbs[0] = lbs[0].substring(1, lbs[0].length);
for (var i = 0; i<(lbs.length-1); i++) {
myLoc = lbs[i].split(":");
}
} else {
lengthsGrid.error = "Server not responding";
feedback.text = "weight failed";
//or notify of failure
}
lengthsGrid.gotoAndStop(5);
};
lengthsGrid.gotoAndStop(1);
mySell.gotoAndStop(1);
feedback.text = myShape+mySection+"x"+myWeight;
product.text = myShape+mySection+"x"+myWeight;
fubar = myShape+mySection+"x"+myWeight;
weight._alpha = 100;
for (x=0; x<material[feedback.text].length; x++) {
section.addItemAt(x, material[feedback.text][x]);
}
};
// Add Listeners.
shape.addEventListener("close", shapeListener);
section.addEventListener("close", sectionListener);
weight.addEventListener("close", weightListener);

falltimemusic
12-19-2005, 10:29 PM
Make sure you're running the SWF outside of the authoring environment. I get problems a lot trying to do that with Test Movie!

also you might want to consider this


uniqIdn = random(50000000);
weightOut.sendAndLoad("http://192.168.0.3/myData.php?uniq="+uniqIdn, weightIn, "GET"); //get results returned


i dont think that has to do with your problem, but sometimes ive noticed that it will cache the results of the php file and keep on using them for later. (annoying huh)