March 30, 2007
ActionScript 3 FedEx Libraries
I just checked some ActionScript 3 libraries into to Google code for accessing the FedEx web APIs. They aren't 100% complete, but they support a fair amount of functionality like:
- Tracking packages.
- Shipping packages.
- Deleting shipments.
- Registering for meter numbers.
- Request a Signature Proof of Deliver.
The package is checked in as as3fedexlib. I expect to be adding additional functionality over time.
Posted by cantrell at 09:19 AM. Link | Comments (5) | References
March 28, 2007
vCard Parser in ActionScript 3
I just checked the vCard parser that I wrote for Maptacular into the as3corelib Google Code project. The entire project is available here, or you can go right to the vCard parser here.
It's simple, but it gets the job done.
Posted by cantrell at 03:18 PM. Link | Comments (5) | References
September 27, 2006
Getting Dictionary Definitions in ActionScript
There's a little known protocol out there called the "dict" protocol which enables clients to connect to a dictionary server and query it for definitions. Servers can (and usually do) host multiple dictionaries, many of which are specialized. For instance, a single server might host the "freedict" standard dictionary, some translation dictionaries, a thesaurus, and maybe a dictionary specific to computer jargon (FOLDOC: The Free Online Dictionary of Computing).
I wrote an Apollo application called "Lookup" which is a versatile dictionary client. It lets you choose a server, choose a dictionary on a particular server, and interactively query it. I'll release Lookup as soon as there is a public Apollo release, but in the meantime, I went ahead and checked the dict protocol library into the Adobe Labs source code repository. If you think you might have a need to look up words from ActionScript, check it out. It's not well documented, but if you start with the Dict class, it's pretty easy to figure out.
- The dict protocol package on Adobe Labs.
- How do get Adobe Labs source code.
- The Dict Development Group homepage.
- Dict protocol server list.
- The dict protocol RFC.
Posted by cantrell at 09:00 AM. Link | Comments (3) | References
August 17, 2006
ActionScript PNG and JPEG Encoders Updated
In October of 2005, Tinic Uro ported a PNG and a JPEG encoder to ActionScript 3. Shortly after, we added both to the collection of free ActionScript libraries on Adobe Labs. Tinic wrote them for an early alpha release of Flex Builder, so at some point along the line during the evolution of the compiler and the player, they stopped working.
I just checked in new versions of both that now compile and pass simple tests against the Flex 2 release. The PNG encoder is here, and the JPEG encoder is here. Let me know if you find any problems with them.
Posted by cantrell at 02:11 PM. Link | Comments (13) | References
July 27, 2006
A Proxy-savvy Socket in ActionScript 3
I'm working on an Apollo application that needs to make a TCP connection on a "non-standard" port, which, depending on your environment, usually means a port other than 80, 443, and few other commonly used ports. Development was going fine thanks to the new ActionScript 3 socket object until I went into the San Jose office to work for a day and discovered that the San Jose firewall is much stricter than the San Francisco one, and the port I was trying to connect on was blocked.
Fortunately, most environments with strict firewall rules also provide a way to get around them in the form of an HTTP proxy. After a little research and conferring with Chris Brichford, an Apollo engineer, we decided that this is a common enough problem that it would be worth solving in a generic way. So I wrote the RFC2817Socket class.
RFC 2817 "explains how to use the Upgrade mechanism in HTTP/1.1 to initiate Transport Layer Security (TLS) over an existing TCP connection." Not entirely relevant to our problem, however it also "documents the HTTP CONNECT method for establishing end-to-end tunnels across HTTP proxies" which means we can use a common HTTP proxy to make TCP connections on non-standard ports.
The RFC2817Socket class works exactly like the flash.net.Socket class, but if you give it proxy settings by calling setProxyInfo before calling connect, it will first handle the negotiation with the proxy server before dispatching the Event.CONNECT event. (If you don't set proxy settings, it will work just like the standard socket class.) All you have to know is your proxy server's hostname and port number, and RFC2817Socket takes care of the rest.
Unfortunately, this may not be the entire story, though. The reason I chose such a clumsy name for the class is that it will only work with proxy servers who adhere to RFC 2817. I suspect that most, if not all, proxies will use this technique (since it is a "standard"), however since I don't have a bunch of other proxies to test with, I have no way of knowing for certain. If it turns out that other proxies use different techniques for tunneling TCP connections, the thing to do would be to create other implementations in the same package, and then create a factory to return the right one. I'm hoping that the RFC2817Socket will work with most proxies out there so that won't be necessary, however if you find that it doesn't, it shouldn't be difficult to write one that does (if I can access the proxy that it doesn't work with, I'll even write it myself).
I should also mention that the entire tunneling portion of the RFC isn't implemented yet, so it doesn't do things like authentication and a couple of other things that are defined in the RFC. Adobe's proxy only uses the very basics, so that's all I implemented for now. If there's a demand for it, I'll add more.
For more information on how to get your hands on the RFC2817Socket class, or any of the other Adobe open source ActionScript 3 libraries, check out the this page on the Adobe Labs wiki.
Posted by cantrell at 10:41 AM. Link | Comments (2) | References
July 25, 2006
ActionScript 3 Makes My Life Easier
Now that I'm back and building Apollo apps, I'm obviously spending a lot of time with ActionScript 3 again. I've been using AS3 since there was a compiler capable of compiling it, but during my sabbatical, I wrote primarily Java and ColdFusion code. Now that I'm back, I have the pleasure of rediscovering all the things I love about ActionScript 3, and all the ways it makes my live easier than it was in the AS2 days:
- Enhanced "for" loops. Being able to use "for..in" and "for each..in" is a huge time saver over the course of several days of programming. Make sure you know when to use which, though.
- The "as" operator. There are two ways to cast objects in ActionScript. The usual syntax of "SomeObject(someValue)" and the new "as" operator. For some reason, I've come to prefer using the "as" operator in many circumstances, I think because I often realize that I need to cast something after I've typed it, so using "as" lets me do the cast without having to move my cursor back. It's also slightly more readable, in my opinion. (It's a small thing, but when you write enough lines of code, small things add up.)
- Regular expressions. All I can say about regular expressions is: how did we ever program in ActionScript without them?
- Sockets. I never felt like ActionScript was blatantly missing a socket object, but now that it's there, it opens up so many new possibilities (which I'll be posting about soon).
- e4x. Once you've used e4x to manage XML, you'll never want to use anything else. I got a heavy dose of e4x early on when I wrote the RSS/Atom library, and I got so used to it that dealing with XML in any other language is a huge bummer now. e4x makes using XML as easy as not using it.
Of course, there are a lot of other things about AS3 that I love . I know they've been thoroughly covered in the Flash blogosphere, but I'm having so much fun writing Flex 2 / ActionScript 3 code again that I couldn't help adding one more post. You can check out several examples of these things in action in the Adobe Labs source code repository browser (which I wrote in PHP, by the way, wishing the entire time that I could write it in AS3).
Posted by cantrell at 09:38 AM. Link | Comments (3) | References