11 Replies Latest reply on Nov 5, 2007 7:47 AM by kglad

    AS3 best method

    Damon Edwards Level 3
      As of now, im using URLLoader to send a variable to a php file and use that to connect to mySQL, the php file then echos back an XML with the results. Once that is back in flash I parse it out and use the data. Once I receive the data my application begins to run extremely slow. I've removed the listener once the load has completed, i've tried loader.close(). So this is my question, is it possible to use the URLStream in this case? Will that have any effect? Or is there a better way to go about this. I'm only grabbing, as of now, about 10 values from the database, but there will be a lot more I need to get. So if it is lagging down to a crawl already, then something must be wrong.
        • 1. Re: AS3 best method
          kglad Adobe Community Professional & MVP
          something else is causing a problem. i haven't noticed sending and receiving variables/values via php taking any longer in as3 than as2.
          • 2. Re: AS3 best method
            Damon Edwards Level 3
            Sending and receiving isn't the problem, the problem is after I have done that, the rest of my application runs terribly slow. I get the variable very quickly. It almost seems like it just keeps sending data back and forth, slowing the app down...
            • 3. Re: AS3 best method
              kglad Adobe Community Professional & MVP
              lol, on that trace(). hadn't noticed that before.

              use a trace() function to see if your xml.getBytesLoaded() is doing what you expect or whether it continues to increase or reset. check your xml.onLoad to make sure that's only executing once.

              and finally, you can always comment-out your xml processing in your onLoad method and see if there are any problems. most likely it's your processing of the xml data that's causing the problem.
              • 4. Re: AS3 best method
                Damon Edwards Level 3
                Haha Thanks.

                I've traced out the PROGRESS event on my loader object, and it does stop at about 1meg. Strange is it doesn't know the total bytes... I'm no using an onLoad function, since I'm not really loading in a XML file per say. The PHP is echoing out XML. Let me post some of the script so you can get a better understanding...
                • 5. Re: AS3 best method
                  kglad Adobe Community Professional & MVP
                  that looks like an endless loop that should bring your swf to a stop if password.client.pass is anything other than "1".

                  you have a COMPLETE event that calls completeHandler and in completeHandler you don't remove that listener unless password.client.pass =1, and you again call the same php file.

                  and why are you defining loader (a duplicate reference to varLoader) and never using it?
                  • 6. Re: AS3 best method
                    Damon Edwards Level 3
                    if the password the user enters matches the one in the database, the php file will echo back the xml file and the number 1, to let me know the password matched, then I grab all variables it sends me.. Is this creating an endless loop? That would explain why it is bogging down my app... How can a put a stop to the loop?
                    • 7. Re: AS3 best method
                      kglad Adobe Community Professional & MVP
                      oops, no that's not an endless loop. your varLoader.load() statement is outside completeHandler(). i thought is was inside completeHandler().

                      does your php while-loop finish looping?
                      • 8. Re: AS3 best method
                        Damon Edwards Level 3
                        I didn't think there was an endless loop there...;). That is what I was thinking too, if the php file is endlessly looping and sending out an XML file, then that might cause this.. but on the other hand, my completeHandler gets executed and I remove the listener at that time. So would it event matter??
                        • 9. Re: AS3 best method
                          kglad Adobe Community Professional & MVP
                          i would test by having your php echo something to flash and have flash trace something each 10th or 100th loop to see if that's an infinite php loop.
                          • 10. Re: AS3 best method
                            Damon Edwards Level 3
                            Okay, after having my comp shut down all weekend, then running this app fresh this morning, it is running nice and smooth. My comp must have been lagged down, since I normally dont turn it off ever. I'm still going to look into optimization, I get some serious CPU spikes when running this. Not when it is just the SWF, but when it is packaged as the AIR app. I guess that is why AIR is still beta... Thanks for sticking with me on this.
                            • 11. Re: AS3 best method
                              kglad Adobe Community Professional & MVP
                              you're welcome.