-
Odd button code results
I have a movie that is connected to a database. It pulls info, stores it in an array and displays it. We also have buttons that are coded to send a search query (selected from the data pulled from the database) back to the website to be displayed. Weirdness happens. Here is the button code.
PHP Code:
on (release) {
getURL("http://www.mysite.com/mySiteBuilder.php?tagged=true&UpdateSearch=update&myRouteResults="+_global.taggedRoutes[0][6]+"", "_self");
}
What happens is that you get is this:
PHP Code:
http://www.mysite.com/mySiteBuilder.php?tagged=true&UpdateSearch=update&myRouteResults=1414,2626,2525,1919,1212,
All is good here accept for the 1414,2626,2525,1919,1212. These should be 14,26,25,19,12! Checked it and it does perform correctly. Why am I getting doubles?!!! Not sure how to correct this in the button code. Please give me clue!!!
-
Senior Member
1.) I would check the var you are sending to php script..
2.) check the code you get back FROM php (before having it back to flash?
should give you a point of entry for trouble shooting..
-
Thanks
I guess what you are saying is that you do not see any glaring errors in that script that would cause it to print the "info" twice. Could be a situation where Flash is retrieving the information from the database as "doubles"?
Thanks so much for ringing in.
-
Senior Member
correct (sorta) lol
I mean that 1 line of code is really 'nothing'...
I think first and foremost you should find out what value this is giving your query string:
_global.taggedRoutes[0][6]
trace("VARIABLE CHECK: "+_global.taggedRoutes[0][6]);
and see what number(s)/data it gives...
if thats wrong.. you know you are sending your PHP script the wrong data..
and you can then check the integrity of the data n the array, and follow back to where/how you are populating that array with its data.
make sense?
-
Sure does make sense. I would love the ability to do the trace but I am doing all testing on the server and do not have a local set-up of site and database. Is there a way to trace to a text field?
-
Senior Member
I guess Im not following..
you do NOT have access to the .fla? so your not testing.working on the flash side of things?
-
Sorry for not clarifying. Presently, I do not have the database set up on my personal computer. I publish the file the FLA and upload it to the site for testing. I am not aware of any way to test the swf on my local computer and have it connect to the live site and database. Am I missing something here?
-
Senior Member
you can run & test the .fla/.swf locally..
permissions aside..
if you use an absolute path (ie: http://www.whatever.com/someScript.php) to the php script..etc there is no reason why it wouldnt work.
I have stuff on-line and test from local machine all the time
however in this case.. we dont even need to get that far.
Firs just check what the data is from the flash project/variable that is being added to the URL string that is eventually being sent to the php script..
-
Too your advice. Found a text field that I pointed that variable to and they are showing as doubles. I am checking with the database guy to make sure that the database is not releasing the information as doubles. If not there, I will have to figure out how Flash is translating that data. It is certainly supposed to be only 2 digits.
You responded to a post I had a few days ago. My client had me trying to figure out a timing issue. Turns out he broke something on the site. Everything is back to normal but I still need to understand that code.
-
Senior Member
I answer TONS of posts and emails.. and to b honest I dont even TRY to remember ANY of them.. (for sanity sake)
so if you want help on another project..have to link me to it and start over on what you need/want done... or whatever specific questions you have...etc
for this one (project) though..
where is this array getting its data from:
_global.taggedRoutes[0][6]
I mean does this Flash app communicate with php/database BEFORE it makes the getURL() call??
something INSIDE the .fla is creating and populating that ARRAY with data..
and THAT is where the error lies IMHO..
its populated with the wrong info..(doubles I guess) withotu seeing the whole code.. there is no use except you trying to 'troubleshoot'
-
You don't remember every post? Arrrggg! I absolutely understand. Once again I agree with you. More than likely the issue is the _global.taggedRoutes[0][6].
Ive got a series of say 4 buttons that are sending various queries back to PHP. They are all _global.somename[0][6] and all give doubles.
I am trying to get the database guy to give me a map of all the data coming from the database. So I can be more sure about things. He is dragging his feet a bit. In the mean time I am moving with what I can figure out on the fly.
Here is a link to the posting.
http://board.flashkit.com/board/show...46#post4246546
This thread was done due to my client jacking up a php file and then blaming Flash for 3 weeks. Had him revert and all the problems went away. However, I still think there is an issue here and I just need to have a better understanding of how it works. If we are thinking correctly, the answer is in that code. Probably a syntax error or the sort.
-
Senior Member
well I gues Im still unclear..
HOW is that array being populated?
do you hit a database for data to populate that array FIRST? (I didnt think so at first)
you only hit the database AFTER you send that data in the URL string to the php script.....correct?
-
Progress.
I jumped into that code and got rid of the doubles. It seems there was some duplicated code. Here is what I changed.
PHP Code:
function handleResult(userObject) { _global.userRoutes = userObject.__result[0]; _global.featureMember = userObject.__result[1]; _global.zipcodeRoutes = userObject.__result[2]; _global.taggedRoutes = userObject.__result[3]; routeInd = ""; _global.featureMember[0][6] = grabUserRoutes(_global.featureMember); _global.zipcodeRoutes[0][6] = grabUserRoutes(_global.zipcodeRoutes); _global.taggedRoutes[0][6] = grabUserRoutes(_global.taggedRoutes); for (v4 = 0; v4 < _global.taggedRoutes.length; v4++) { for (v3 = 0; v3 < 7; v3++) { trace("The userRoutes : " + _global.taggedRoutes[v4][v3]); } trace("new object"); } for (v4 = 0; v4 < _global.zipcodeRoutes.length - 1; v4++) { _global.updateDataFunction.addData(v4, this.debug, "routeData", _global.zipcodeRoutes[v4 + 1]); } } function grabUserRoutes(routeArray) { zipRoutes = ""; var v1 = 1; while (v1 < routeArray.length) { var v0 = zipRoutes + routeArray[v1][5] + ","; //was missing a comma zipRoutes = zipRoutes + routeArray[v1][5] + ","; //v0 = zipRoutes + routeArray[v1][5] + " ,"; //zipRoutes = zipRoutes + routeArray[v1][5] + " ,"; // is duplicate code it seems. (v1 == routeArray.length - 1) ? v0 : v0; v1++; } return zipRoutes; } function handleError(fe) { trace("There has been an error"); } var userRoutes = new Array(); var userId; _global.updateDataFunction = new routeData();
_global.debug = false;
var gatewayUrl = "http://www.mysite.com/amfphp/gateway.php";
var _service = new mx.remoting.Service(gatewayUrl, null, "TwoWheelDataBaseQuery", null, null); var _pendingCall = _service.updateUserRoute("Random", "", true); _pendingCall.__set__responder(new mx.rpc.RelayResponder(this, "handleResult", "handleError")); _global.dataOut = new LoadVars(); updateDate = function () { _global.dataOut.checkSession = "check"; _global.dataOut.onLoad = function () { _global.dataOut.sessionCheck = dataOut.sessionCheck; _global.userId = dataOut.userId; trace(this.userId + " Userid " + _global.dataOut.sessionCheck); }; _global.dataOut.sendAndLoad("../Loginflash.php", dataOut, "POST"); }; onLoad = function () { updateDate(); };
This gives me the singles I have been looking for. Now, it still puts a comma on the end of the string like so:
http://www.mysite.com/ThingyRouteBui...14,26,25,19,12,
If I can get Flash not to place the comma, I think this one is hooped.
-
ONe post behind. Yes we hit the databse first and store the arrays. The go button only references it and sends a part of it back in the query.
-
Senior Member
can you post a sample route array/data so I can test some code?
here I guess it doesnt matter..
but since you are manually appending the comma.. i guess you need to check when you are done (v1 = array.length-1)
and then NOT append the comma to the end:
example: (fit it into yoru code as you see fit)
actionscript Code:
if(v1 != routeArray.length-1){ zipRoutes = zipRoutes + routeArray[2] + ","; }else{ zipRoutes = zipRoutes + routeArray[2]; }
Last edited by whispers; 04-28-2010 at 06:36 PM.
-
Whisper.
Thanks a ton!! I changed it to this and it works like a champ!!
if(v1 != routeArray.length-1){
zipRoutes = zipRoutes + routeArray[v1][5] + ",";
}else{
zipRoutes = zipRoutes + routeArray[v1][5] ;
}
Thanks so much for your help. You rock!!
Question. To better help me discern what is being sent back and forth from flash and php and the database. Is there a way to log this information. An application or so? In the Firefox Browser?
-
Senior Member
ya know I 'think' Firebug (or one of its add-ons, liek flashbug or firephp).can do stuff like that.. but I have no clue as I dont use that extension.. (but probably should) lol
you do understand why you had to do that fix..right?
you were manually adding in the comma after each iteration...
but in reality you wanted to do it on every iteration of the while() loop.. EXCEPT for the last cycle..
so you basically check each if you on the last iteration of the cycle/loop..
and if yes.. then you just add the data, without the comma at the end.
-
That makes sense for sure. I am still working on getting totally up to speed on these type Flash things. Your help has been amazing. All the right buttons pushed. THANKS
I will look into the Firefox add on. I have Firebug. Will see what I can find.
-
Senior Member
this 'knowledge' is considered OLD now...
AS3 has been here for a while..and it seems its the 'BUZZ' word in resumes if thats your scene.
but alas, I only know AS2.
-
S*&^ . AS3?!!! Dude what a joke! Hell, I can't wrap my old brain around 2. AS3 is like a train wreck to me. I'm the boss and if I reallllly NEED AS3 I will hire someone. Right now I am busy enough with the last developers mischief.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|