Author Archive

Technology

Building AIR applications with just the command line

I had a moment today where I wanted to find out some more information about Silverlight. I looked around but was unable to find any path to building the plugins with anything but the Visual Studio environment. That frustrated me quite a bit. At that point a friend pinged me to tell me a story of woe about his unsuccessful attempts to build AIR applications without one of the formal IDE’s. And while I had used the AIR SDK to launch and build HTML JS example applications I had never tried to build one using the Flex SDK. He challenged me to grab any example code on Adobe Labs and compile and launch the application using just the command line tools.

I accepted the challenge (beer me) and thought I should talk about how to build an AIR example application that was created in Flex Builder using just the free SDK tools. The first step is to actually download and install both the Flex SDK and the AIR SDK. I unzipped these folders and added the bin directories of each to my $PATH. Now I could execute any of the mxmlc or adl tools from the command line. Next I retrieved the source code for a flex based example application in AIR. After unzipping the the the source code and `cd`ing into the src directory I decided to just give a go at compiling the code. Using mxmlc gave me an error about the compiler no knowing what a WindowedApplication element was. So I added the air folder in the frameworks/lib directory of the flex sdk to my -source-path. Now my application compiled fine using the following command.

mxmlc -library-path+=/System/flex_sdk_3.0.0.477/frameworks/libs/air HTMLScout.mxml

This created a HTMLScout.swf file in the same folder as the .mxml file. Then after looking at the mxmlc options for a bit I realized I could skip that long scary path by just using the configname parameter.

mxmlc +configname=air HTMLScout.mxml

Which also compiled just fine. But just because Adobe knows that in general programmers are lazy, they also created the amxmlc executable which as you might guess, adds that config parameter for us. So to compile an MXML file inluding the AIR libraries we just

amxmlc HTMLScout.mxml

So now we have a swf that can be used as the content for our applications. Because when it comes right down to it AIR is just a wrapper for our content exposing a little more functionality than we have in the browser. So we can set the initial content of our AIR application to be any html or swf file. The trick here is that when using Flex Builder to create your AIR applications it sets the initial content property for you. But when compiling from the command line we have to have that set explicitly. So open up the application descriptor file for the example application you downloaded and look for this line.


<content>[This value will be overwritten by Flex Builder in the output app.xml]</content>

You need to change that to actually have a value that represents your base content. In my case the value needs to be:


<content>HTMLScout.swf</content>

Save that application descriptor file and use adl to launch your AIR application.


adl HTMLScout-app.xml

Sit back and bask in the glory of building applications that run on Mac, Linux and Windows for no cost at all. For more information please check out the following 2 pieces of documentation.

AMXMLC
http://livedocs.adobe.com/flex/3/html/CommandLineTools_2.html#1043794
Application Descriptor File
http://livedocs.adobe.com/flex/3/html/help.html?content=File_formats_1.html#1043413

Technology

Revisiting the HTTPService Classes

Ok, So HTTPService piece of cake right? You declare it in mxml and you set the url property and when you are ready you call send() and maybe if you need to pass some parameters. Couldn’t be any easier.

Except what if you want to use the HTTPService class from ActionScript? Well its not much harder. Just declare a new instance of the HTTPService object and… wait code completion tells us there are two HTTPService classes in the framework. One is in the mx.rpc.http package and the other is in the mx.rpc.http.mxml package. Seems like a pretty clear line there huh? One is for MXML and the other is not. But the problem is in the little things you might have gotten used to by using HTTPService in mxml, things like the showBusyCursor property. That property and its functionality are defined in the mxml package version of the class. Ok, well easy enough, import the HTTPService class from the mx.rpc.http.mxml package and use this to your hearts content. All is well that ends well and now we can move on.

Except… there are a lot of properties on the HTTPService object that are strings. But not any string will do. Think about resultFormat, and contentType. Compiler wont error by typing the wrong strings but at runtime we will get a yucky error if we have a typo. So the solution is to use some of the static constants that are declared on the mx.rpc.http.HTTPService object. This fixes the problem by giving us compiler warnings for invalid options. But you will notice above we decided to use the HTTPService object from the mxml package, and it doesn’t have these constants declared. So now we have a new problem. To use good practices and make use of the constants declared we have to use the main HTTPService object (can’t import more than one class with the same name) but then we loose that cute showBusyCursor feature. What will we do?

Not to fret, we can do on our own what the showBusyCursor was doing for us. Using the CursorManager class we can call the static method CursomManager.setBusyCursor(). This causes that cute little clock to show up for us. Then in our result event for the service call we use the static method CursorManager.removeBusyCursor().

So in the end… use the mx.rpc.http.HTTPService class from ActionScript. Its better for programmers and you can make up for what is missing the mxml version of the class.

Technology

ArrayCollection with Multiple Filters

At the Adobe Community Summit a couple weeks ago I had the opportunity to help teach the AIR Flex course. It was a lot of fun and I think of all the events that week doing that helped me meet more people. During the class I answered a lot of questions, but there were some that I didn’t have an immediate answer for and I said I would look into it.

One such question came for Adrian (I think…) and he had a problem where he needed to apply multiple filter functions to a single ArrayCollection. We talked about a couple of the ways I would approach it but I didn’t really like the options I was presenting. After I got back I did a couple google searches and found this example. I think Cristian did a great thing here by extending the functionality of the ArrayCollection to support this behavior.

My only wish was that we could still grab the prototype on the AS3 objects so I could mix in the behavior change rather than have to use a new data type through out my applications. But I guess I will take speed fixes in AS3 and accept that it is strictly typed for a reason :)

Anyway, I think Cristian’s solution is good enough and I hope Adrian sees this.

Technology

Say no to google or be beaten

Ok, so people laugh at me when I say that 2008 will be the year I abandon google. “Why on earth would you want to do that?” I hear all the time. And my usual answer is that while I am too young to have been affected by the “red scare” I feel that google prominence in the web and as a data collection agency, puts us on the brink of a much worse time. I accept that perhaps I am being a bit eccentric and take the jabs and wear them well.

But its articles like this one today on slashdot that reaffirm my fears over googles position in the world market place. After being asked by the authorities for the identity of an Orkut user, google handed over the information. If we are to believe what the article says:

He was arrested and is reported to have been beaten by a lathi and asked to use the same bowl to eat and to use in the toilet.

Obviously the punishment was not handed down by google, but they certainly broke all barriers of trust by caving to authorities. I understand that this is in a foreign land, and their customs are not the same as ours. But this attitude about offering up information about users and their online habits is just one reason that we should all be weary of the power of google.

So the next time you grab a feed from feedburner (which i still use), look at a site displaying adsense (which I still use), or search for that hard to spell word in the foreign dish you are about to make. Google is watching and they are creating a profile about who they think you are. Who will google tell the government you are when the next terrorist attach happens?

And this is why I am working to abandon google services. I recognize that its not just a drop and run thing. I use too many of their services myself. But I am slowly replacing their services with the hopes that I can stop writing myself into their mischief log. In fact I found this article while reading posts in Rojo my new online rss reader which has now replaced google reader in my life. Thats one more google service I need not worry about.

Technology

Yeah, just call me a git

I have started using git for most of my projects. It started as a way for me to continue working with my SVN repositories when I was offline, but as I got more familiar with the application I found I was choosing it over svn.

Why choose it over svn? Because I truly believe that if you are not versioning your code, you shouldn’t be writing code. Why don’t people use versioning systems? Because they are hard to work with and they get in they way. Having to go setup repositories and such can be a major pain. Git is simple. After installing git, CD to the directory of your project and type `git init`. Thats it. You are now ready to start writing code and making commits. Want to share your code with someone? Just zip up the directory and send it to them. Your single .git folder that is at the root of your project contains all the information they need to checkout the history of your work. Don’t want to share your history? Don’t send the .git directory with it :)

Git is a distributed version control system. What does that mean? There does not have to be a single central repository. Any single users copy can be cloned and published and shared on a network sever and accessed via many protocols.

What prompted me to write this post was actually this article on useful git utilities. My primary interaction with git is via the command line and sometimes I dont remember all the options that are available. Using this bash script will allow you to get auto completion for all the git commands. Nice! The trick is to just save that bash file to your home directory and then source it into your path. On the mac, you can edit your .profile file to add the line `source ~/git-completion.bash` (don’t put in the `’s though).

Go on now, get your Git on!

Technology

SWF Specification is a Cookbook

I read this and though it was a great description of what the SWF specification having the restrictions removed does for us. Lets pretend you had some cake at some fancy dinner. It was amazing, and delicious and suspiciously light on calories. Adobe opening the spec on Flash Player SWF file, is like giving you the recipe to a prize winning and amazing cake. It does not provide a free cake, nor does it provide the ingredients to make the cake, but it does tell you how you can make a cake. Now you can make the cake and share it with friends or sell it or whatever.

Thanks to Dave for Open at Adobe: Cooking with SWF, and the understanding of copyright

Meta, Technology

I can’t post date my entries in wordpress

Maybe someone out there can help me with this. Sometimes I feel like blogging, and sometimes I don’t. Sometimes when I feel like blogging I don’t want to publish a bunch of articles in a row (like today) so I like to post date my entries so they will pop up in a couple days keeping the information on my blog fresh. The dashboard in wordpress says I have 3 scheduled posts. All of them are a couple months old that never went out when the time passed by.

Has anyone else seen this are put together a fix? TIA

Technology

Yahoo AS3 Map Component

When I recently started Geocaching I found that I wanted to have some kind of log that helped me keep track of what caches I had found and which I was still looking for. There are several of these on the market, but I saw this as an opportunity to build something cross-platform and with a rich mapping interface. So I started working on GeoLog, and application that uses the GPX files I download from Geocaching.com to display their location on a map. Thats about as far as I am with the application but I think this could be a great tool for all geocachers when I get done.

The core functionality of the application right now is the map interface. Since I am building this in AIR I saw no reason not to take this opportunity to use the Yahoo AS3 Map component. This is my first mapping application and I can not imagine yahoo having made this any easier. There are a whole bunch of examples and demos with code for how to do most tasks.

The map from yahoo is an AS3 component which I don’t think has any ties to the Flex framework. So when using it you must instantiate it and then add it as a child to a UIComponent in your appliaction. While this approach is fine, I wanted to encapsulate it a bit for my application. So I created a new Actionscript class and extended UIComponent. I then overrode the createChildren and updateDisplayList methods to implement the adding and manipulating of the yahoo map. I am posting the code for YahooMapViewer.as below in case anyone is interested.
Continue Reading »

Personal, Technology

Yet another addiction in my life - Geocaching

Ok, I will admit it, I have an addiction. Last week I bought my first GPS unit and I wanted to play with it. So I had heard people talk about geocaching, but I didn’t really understand what it was. So I visited Geocaching.com and read about the process. I searched and found a couple caches near my house ( a couple really near, but 50 within 5 miles). And I took my wife and my daughter out and went searching. WE HAD SUCH A BLAST! And we found nothing. :) Since that first night I have gone everyday and found at least one cache, although I usually look for a few.

This weekend we took a drive to the coast with Ryan and Ciara to show them around where I grew up. We found one out by the river. After Ryan and Ciara headed back to Seattle I hooked up with my dad and my brother and we went on to find 8 more caches that day! After coming back to portland my daughter and I went for a bike ride and found a couple more.

GeoCaching has been a wonderful combination of technology and nature, and just enough of a reason to get out of the house and go do something. If you have a GPS I really want to you to try geocaching. If you don’t have a gps? Well now you have a reason!

Keep an eye out for GeoLog an AIR application I am writing that uses the GPX files from geocaching.com and the AS3 Map Component from Yahoo to help you manage your geocache collection.

Technology

Mozilla cries like an ungrateful child

I was just going to comment on this article but CNET doesn’t support OpenID and I am not about to go making another account, so I’ll post about it here.

In the article Mozilla speaks out against the free-but-proprietary Web apps the author discusses the problems with free but proprietary software. In a quote from the Mozilla Europe’s founder:

“Both Adobe and Microsoft have been willing to give (Flash and Silverlight away) for free. But maybe they have an agenda. They’re not here for the glory; they’re here for the money.”

I really think this is ridiculous. With all of the products that Adobe has open sourced in the last two years, for them to even consider that they have an alternate agenda is just a little bit ridiculous. Not to mention that the core strength in the Flash player is the AVM2 (Actionscript Virtual Machine) which was donated to the Mozilla foundation (tamarin project) and is slated to provide the core functionality for the JS implementation of Firefox 4.

The recent news the article mentions that makes this statement total bullshit is that Adobe has released the full specification for SWF and FLV formats. And while there is not (yet) a viable Open Source alternative to the Adobe Flash Player, there is nothing stopping someone from building one now. They even have the the core technology for making it work in the Mozilla Tamarin project.

So while not all of Adobe’s tools are Open Source they have provided free and open source components to almost all of the technologies that the open source community might care about. Mozilla needs to quit it’s crying, they choose to go open and not for profit. They choose the life of the meaningful and enlightened (but poor) software provider. And they cry afoul when other companies don’t do the same. But I think the real problem for them here, is that a for profit company that is very successful in building great software and client relationships has also seen the benefits that can be received through opening up software. And now they are upset that not only does Adobe make lots of money on great software they are also giving great software away just to enrich the developer community.

Perhaps if Mozilla had gone the other way and built software to sell they could pay someone to fix the problems with Firefox crashing all the damn time. At least when a new flash player comes out its faster, feature-ful and stable. I am still looking for a version of firefox that can load up Gmail without crashing. If that is what software built with no agenda does, then I don’t see the point. What is the purpose of building software with no agenda. Especially if it leads me to use tools that are not based on open standards just so I can get through my day without wanting to through my computer.

« Prev - Next »