PaperKingdoms

September 9, 2009

Bit.ly in AS3

Filed under: actionscript, code, flash, internet, web development — bardicknowledge @ 8:42 am

I know this is pretty damn simple, but in case you’re in a hurry here’s a quick example of using bit.ly in as3 i whipped up. This is really just the basics. I will likely expand on it, but you can get the gist.

  1. Download as3corelib : http://code.google.com/p/as3corelib/
  2. Sign up with bit.ly : http://bit.ly/account/register?rd=/
  3. That’s pretty much it….


import com.adobe.serialization.json.JSON

var login:String = "put your bit.ly login here";
var api:String = "put your bit.ly api key here. It's on your account details page";
var url:String = escape("the url you want to shorten");
var bitly:String = "http://api.bit.ly/shorten?version=2.0.1&longUrl="+url+"&login="+login+"&apiKey=" + api;

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(new URLRequest(bitly));

function completeHandler(ev:Event):void
{
var bitlyObj:Object = JSON.decode(ev.target.data);
var o:Object = bitlyObj.results[url];
if(bitlyObj.statusCode == "OK")
{
trace("Success! Short URL is : " + bitlyObj.results[url].shortUrl);
}
}

That’s pretty much it. I didn’t write my error handling yet, but it’s pretty simple. Just trace out ev.target.data to see the JSON structure in case you need more details ^^

Hope it helps

*Updated to add the escape to the URL.

September 4, 2009

I can’t be the only one…

Filed under: culture, musings, philosophy, rants — bardicknowledge @ 2:02 pm

I’ve been doing a lot of thinking of lately and soon I will be living alone for the first time since my accident. I have avoided living alone the last four years due to frequent slumps of depression I slide into but I figured it was time for me to face this aspect of my life and either beat it or let it beat me. Either way is acceptable but the first option is likely the most pleasant.

I really can’t be the only person out there that has a hard time dealing with people. Others must be the same. Others must not want to talk to people, be it on the phone or in person. Other must also want to avoid conflict, even if it comes at a personal loss. Others. The thing I’m afraid off. I dunno what it is about people that make be want to stay at home, or that make me so angry. Why can’t they see? Maybe it’s just me that can’t see? But either way, I’m pissed about it. Is it really that difficult to be a consider person, to keep your word, to not only ever look out for number one?

This is my main problem with society. It’s one for one. It’s almost never all for one, or one for all. No one give’s a shit about anything but themselves. And this is why I avoid conflict. Because I don’t want to start arguing with people that are only looking out for themselves. Because no matter no sound your logic is, those fuckwads will bend it to fit their twisted sense that everything in the world revolves around them.

And it’s these thoughts of people constantly looking out for themselves that make me depressed. Or at least a large part of it. How can you trust someone that only looks out for themselves? How can you tell when they really care or just using you? (this is in no way directed at my girlfriend in case she ends up reading this… which is unlikely).

I dunno. I can’t be the only one. There has to be others out there that care for more than just themselves. But here is the kicker. I’m too afraid of dealing with people to find out.

Oh well. Fuck it. I’ll just live with my depression caused by my perception of society. At least I won’t bother anyone since I can’t stand dealing with them…

Create a free website or blog at WordPress.com.