A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: Odd button code results

  1. #1
    Senior Member
    Join Date
    Mar 2008
    Posts
    160

    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!!!

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    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..

  3. #3
    Senior Member
    Join Date
    Mar 2008
    Posts
    160

    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.

  4. #4
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    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?

  5. #5
    Senior Member
    Join Date
    Mar 2008
    Posts
    160
    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?

  6. #6
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    I guess Im not following..

    you do NOT have access to the .fla? so your not testing.working on the flash side of things?

  7. #7
    Senior Member
    Join Date
    Mar 2008
    Posts
    160
    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?

  8. #8
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    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..

  9. #9
    Senior Member
    Join Date
    Mar 2008
    Posts
    160
    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.

  10. #10
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    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'

  11. #11
    Senior Member
    Join Date
    Mar 2008
    Posts
    160
    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.

  12. #12
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    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?

  13. #13
    Senior Member
    Join Date
    Mar 2008
    Posts
    160
    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 0v4 _global.taggedRoutes.lengthv4++) {
          for (
    v3 0v3 7v3++) {
             
    trace("The userRoutes : " _global.taggedRoutes[v4][v3]);
          }
          
    trace("new object");
       }
       for (
    v4 0v4 _global.zipcodeRoutes.length 1v4++) {
          
    _global.updateDataFunction.addData(v4this.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(gatewayUrlnull"TwoWheelDataBaseQuery"nullnull);
    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.

  14. #14
    Senior Member
    Join Date
    Mar 2008
    Posts
    160
    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.

  15. #15
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    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];
    }

  16. #16
    Senior Member
    Join Date
    Mar 2008
    Posts
    160
    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?

  17. #17
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    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.

  18. #18
    Senior Member
    Join Date
    Mar 2008
    Posts
    160
    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.

  19. #19
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    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.

  20. #20
    Senior Member
    Join Date
    Mar 2008
    Posts
    160
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center