yahoo AS 3.0 weather API with flash
September 30th, 2007
flash 2 comments »
Here’s a pretty simple AS 3.0 example of using the yahoo weather API in flash. Nothing too fancy going on here. I plan to use it for something just a little more interesting than this, but I wanted to share this simple version because there aren’t a lot of non-flex samples out there.
You can see the sample here.
Start out by creating an instance of the WeatherService class:
//establish the weather service class
var ws:WeatherService = new WeatherService;
var w:Weather = new Weather;
Then, use the getWeather method to receive the weather information you’re looking for.
//grab the weather restults when the button is pressed
function getMyWeather(event:MouseEvent):void {
//use the zip code entered to get the weather
loc = zip_txt.text;
ws.getWeather(loc, "ENGLISH_UNITS");
}
getWeather takes just two parameters: your location and the type of units you’d like returned. My sample file is using US zip codes, but there are other location options available.
The full list of APIs available and documentation are here.
And here’s the FLA source for the flash sample.
Another idea for using Adobe AIR
September 9th, 2007
flash no comments »
We delivered an alpha of what will soon be a rather large Flash elearning application at work earlier this week. The plan was to deliver the alpha as something the client could view locally as opposed to over the web for now. While we were talking about it, Wayne came up with the idea of making it an AIR application. Pretty cool idea.
In theory, this could be another way of using the AIR platform — to create a kind of temporary application. When you think of desktop applications you tend to think of things you use often and are more permanent. But, the ease of making an AIR application with existing code (thanks to the Flash cs3 AIR update) opens the door for building temporary applications. Creating a desktop application is as easy as making a selection in your Flash file’s publish settings.
Of course, I said in theory. We can’t start delivering alphas to clients as AIR applications just yet. There are two reasons why.
First, while it’s very easy for us to take existing files and package an AIR application, it is not so easy for a client to view one. As of right now they would have to first install the runtime, and then install what we sent them. Not exactly easy to use from their standpoint. Plus, we would have to explain what AIR is on top of that.
Second, this particular project is written in AS 2. 0 and because of that erros were thrown and the AIR version wouldn’t run. I’ve since tested out a few other AS 2.0 files that packaged up as AIR applications (via the Flash CS3 AIR update) with no problems.
That second reason is very specific to our project, but until we make the move to using AS 3.0 all the time, the same issue could come up.
I’m sure a lot more ideas for this sort of ‘temporary’ application will pop up as adobe AIR becomes more mainstream.