PDA

View Full Version : LoadVars corrupting last value?


CPedrick
03-18-2008, 04:19 PM
I am passing two values, MonthlyCounter and YTDCounter, (the result set of a DB call) to Flash via .asp. The values look fine going in, but when they get written to dynamic text boxes in Flash, the last one displays both the incoming value and, tacked onto the end, the text "bodyhtml".

I have no idea where this might be coming from. It appears to have been added to the text box along with the last incoming value.
Both values coming in are numeric. (I use the Int() function in .asp to make sure they are integer values.) But if I test right after they load into Flash, the last value tests as non-numeric. (isNaN() tests true and the value is set to 0.) If I take out the isNaN() test, I get the incoming value from the .asp page, but the text "bodyhtml" is tacked onto the end.

Here's the actionscript code:

//load variables
var my_lv:LoadVars = new LoadVars();
my_lv.onLoad = function(success:Boolean):Void {
if (success) {
//handle null values and stray characters or set counters to incoming values
if (isNaN(this.MonthlyCounter)) {
mcResults.txtMonthlyCounter.text = 0;
} else {
mcResults.txtMonthlyCounter.text = this.MonthlyCounter;
}
if (isNaN(this.YTDCounter)) {
mcResults.txtYTDCounter.text = 0;
} else {
mcResults.txtYTDCounter.text = this.YTDCounter;
}
} else {
NoResults._x = 90; //display error
stop();
}
}
my_lv.load("IFA10thAnniversary.asp");




For the sake of thoroughness, here is the .asp code which appears to be working just fine:


If not oDataRS_IFA10th.EOF then
if isNumeric(oDataRS_IFA10th("IFATA_MNTH_CNT")) AND isNumeric(oDataRS_IFA10th("IFATA_YTD_CNT")) then 'Write out record values for LoadVars import in Flash
Response.Write "MonthlyCounter=" & Int(oDataRS_IFA10th("IFATA_MNTH_CNT")) & "&YTDCounter=" & Int(oDataRS_IFA10th("IFATA_YTD_CNT"))
'Else
Response.Write("Non-numeric value.")
end if
exit for

End If 'if not oDataRS.EOF then


This returns the following line for loading into Flash:

MonthlyCounter=40&YTDCounter=40

I would *really* appreciate any thoughts on why this might be happening. I'm tearing my hair out and it is an important project.

TIA,
Carolyn

xxneon
03-18-2008, 04:25 PM
have the asp put a '&' at the end of your response your sending to flash... and that should fix it..

CPedrick
03-18-2008, 04:29 PM
May God bless you and your increase for a thousand generations...

That appears to have fixed it.
Carolyn

xxneon
03-18-2008, 04:31 PM
yea its just an easy way to terminate the last value incase there is any 'extra garbage' that gets attached.. like in your case.