Getting The Hang of Facebook Apps
Posted on August 8, 2008Ok, So I’ve given the Facebook API a test run. It’s not that bad once you find all the info you need to get something going.
For the past 2 days I had been working on a new as3 class to help send and receive data from Facebook. Golfsol works like a charm, so I’m not messing with the data stuff on that yet. But my test app was freaking out.
I was able to send data back to the server, no problem, but I was never getting anything back like I expected. My first error, was I over looked the fact that you need to use the URLLoader.load function to actually get anything back. I was using SendToUrl by mistake.
So I added my new loader function and now I still couldn’t get anything back. I ended up adding a bunch of debugging points in the code to catche where things were going wrong. In my URLLoaded event, I could see something was coming back, but never updated any of my debug points.
As it turned out, I wasn’t letting the app run long enough. There was an error on the PHP script, so it was taking several seconds for all the data to get back to the flash application. I let it sit long enough to see something, but it was a bunch of junk. Took a closer look and it was a bunch of urlencoded stuff.
I decoded it, only to find that I was missing a parameter in a couple functions in the PHP script I was testing. Once they were fixed, I was back in business. 2 days of headaches.
On the plus side, I come up with dynamic variable solution that had plagued me for some time. As it turns out in AS3, you can’t use the this[] or eval() to make dynamic variables. It was actually a bit simpler.
Say you have an array name tArray. You can give the array a value like so, tArray["somename"] = whatever; That’s not good enough for what I am doing, as all the values being passed around are in dot format, like tArray.somename. Not knowing I already had the solution, if I give a variable a name with ["whatever"] I can then reference it both ways. Like tArray.whatever
So now that I am getting data back from my server, I can not reference everything by its key value, no problem. Seeing how it’s just an array.
I also found 50 bucks…
Tags: actionscript, as3, facebook, flash
Categories: facebook