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.

June 11, 2009

red5+wamp

Filed under: code, flash, internet, open source, tech, tutorial, web development — bardicknowledge @ 8:50 pm

Well this gave me a bit of a run around, but I have finally (I think) got it all sorted out : red5 running on windows through wamp. This isn’t really that big of a feat but it’s the first time I’ve done something like it and I’d like to explain step by step how to get it working since none of the guides I read held your hand through the whole set up.  So I will ^^

If you don’t know what Red5 is here’s a snippet from Wikipedia that explains the basic idea:

Red5 is considered as a free alternate to Adobe Flash Media Server, and supports many of the same feature sets. It has a few additional feature sets such as the ability to intercept live streams, and the ability to easily plug in other Java libraries such as Hibernate.

So, my first attempt was to use tomcat, but that didn’t work so so well, and since I have a wamp server already running I figured it would be best to use that. After some googling  I found other people that had already done this, on the  Red5 mailing list , here.

Pretty much I’m just gonna copy their nine steps and add my additional comments since their way works, it’s just a little vague though.

  1. Install wamp
  2. Create a directory named “red5-server” into C:\wamp\www
  3. Download and install TortoiseSVN
  4. right-click on C:\wamp\www\red5-server folder and click SVNCheckout
  5. enter  the url from which red5-server will be downloaded : http://red5.googlecode.com/svn/java/server/trunk
  6. download ant from the apache software foundation (manage dependencies for compilation)
  7. Extract ant to a folder where ever you want. Just remember it’s path since you will need to add it to your system variables later. I put it at : C:\apache-ant-1.7.1
  8. Download the JDK 6 and install
  9. Add ant and javac.exe to your system’s Path variable (right click on my computer – > Advanced – > Enviroment Variables – > Find variable Path in System Variables and edit. You need to add the path to the javac.exe which is in your JDK installation (default on xp for me : C:\Program Files\Java\jdk1.6.0_14\bin) and the bat files for ant (C:\apache-ant-1.7.1\bin) . Make sure that each variable is separated by a semi colon or it won’t work.)
  10. open a shell on C:\wamp\www\red5-server
  11. just type ant server – if ant is not found your system variables are set up wrong. If during building it says that it can’t find tools.jar where it expected the easiest solution is to find where the tools.jar file is on your pc and copy it to where the ant expects it. If at the end of the build it says it can’t find javac.exe, you either installed the wrong version of java or your system vars are set up wrong.
  12. You can install samples demo via the administration console http://localhost/RED5-server/webapps/installer/index.html

And there ya go -Red5 through your wamp installation.

July 31, 2007

mp3 player – ActionScript

Filed under: actionscript, code, design, flash, internet, music, open source, software, tech, web development, XML — bardicknowledge @ 8:07 am

Hey for anyone that reads this. It has been a little bit, but I have a new code snippet for ya’s. It’s a pretty simple mp3 player that you could easily embedded on a site.

Here’s there script (link). It uses a pretty simple XML also.

<song>
<t st=”songtitle” l=”url” a=”artist” />
</song>

Give it a whirl. I will be trying to remake it with a slider on the next version and make it smaller.

July 19, 2007

Wishlist for next gen of social networks

Filed under: blog, culture, design, internet, musings, news, social networking, tech, web development — bardicknowledge @ 10:02 pm

So today I was playing around with Facebook and every few days it draws closer to what I really want to see social networks to become like.  So I am going to list for you want I really really want to see in the next gen of social networks.

  • Email
  • RSS
  • Online docs
  • Blog
  • IM
  • Communities/Networks
  • Persistent messaging system
  • Calender

Pretty much take everything Google does, add it to the core of facebook and give it a descent desktop app and you’re set.  But the biggest problem would be not limiting the service you allow people to connect to. If I want to use bloglines, Gmail, Zoho, and WordPress I should be able to.

So that list isn’t just things I want to see aggregated, but features that allow me to interact with them. So I can post to my blog, mark favorites on my RSS stream, create,edit, delete docs, or add events to my calender. I also want to have trusted friend able to edited or add things using the central system.

I don’t see the feature of social networks as just a place to gather and stalk what friends are doing, a centralized portal to who I am and linked to on the internet. I am really excited for the google social network, not because I think it will necessarily be better than Facebook, but because it will be good and it will (hopefully) be real competition for facebook and push the development of Social networks.

July 17, 2007

Fade background color in new color : actionscript

Filed under: actionscript, code, design, flash, internet, open source, program, software, tutorial, web development — bardicknowledge @ 9:53 am

Have ya ever wanted to change your background color during runtime using actionscript instead of having a timeline event? Did you by any change want to have it fade from it’s current color to the new color with the click of a button?

Well, if so today’s your lucky day. For a site I’m working on I needed to make the buttons when clicks change the background color, so I set out to do it. The first and pretty much only problem I encountered was when you changed the background it would show the stage background and not the last color showed. So if I click red and then clicked orange I would want it to fade from red to orange. Well what I was getting was red, white, then fade to orange. But after about 15 minutes or so of playing I figured out a way around it.

So anyways, it works now and you can easily change the speed of fade by changing the alpha added to itself. Here’s the link. Hope it’s of some use to ya’s ^_^

Older Posts »

Create a free website or blog at WordPress.com.