Skip to content

Google API – AS3 library: v. 2.0


I’ve been busy at work, perhaps the reason why it was so silent on this blog.
But I’m back! And one of my first act is to update the Google AS3 Library I’ve build a while ago.

I started the library to support Google’s Ajax search API.
Later on, when I found some new webservices, I added those too. At the end, the entire library was one messy organically grown library.
So I decided a while ago to clean that mess up.

Changes & new features

  • I reordened the package structure, meaning I devided the API in ajaxapi (search, translation and, the newly added, feeds), apicore (where you can store your api key), suggest (using the Google Suggest webservice) and weather (using the weather services).
  • I changed the name of the event GoogleSearchEvent to GoogleApiEvent, which is more relevant since the library is more than the Ajax search API.
  • Dito for the class that unites all features called GoogleSearch, it’s now called GoogleApi
  • As already mentioned, I also added the ability to use an api key.

I hope those changes make the library at least a bit more transparent and easier to get.


If you want to update the library your using, the easiest way is using FDT.

  1. Delete the old library and add the new one instead.
  2. Right-click your source folder, goto Source and click ‘Organize imports’.
  3. This will change your imports and correct them accordingly, so they point to the correct classes.
  4. Correct the eventname, GoogleSearchEvent becomes GoogleApiEvent. You can do that by using a find & replace, same for GoogleSearch to GoogleApi

Gimme, gimme , gimme

The classes are still on Google Code, where a new version of the library has been committed into the SVN.
The old classes have been moved to the branch folder. There is also a new update for GoogleEyes, containing the new libraries.

You can download those libraries here.
GoogleEyes demo app can be found here.

The project is hosted on Google Code (see).

Posted in AS3, Flash, Flex, google.

Tagged with , , , , .

ScreenManager: expand your AIR application (to multiple monitors)

Never wondered how cool it would be when your AIR application runs on 2 or more monitors at the same time?

Adobe AIR supports multi-screen by offering the developer a Screen-class.
This class makes it possible to detect screens, get some info, and that’s it.
To open a window on a screen, you’ll have to do some calculations yourself.

To make positioning screens, moving screens, … easier , I quickly build a ScreenManager that takes care of your NativeWindow(s).
Make an instance of the nativewindow and send it throught the manager.
Like this:

var nw:NativeWindow=new NativeWindow(new NativeWindowInitOptions());
var mc:MovieClip=new MovieClip(); //movieclip with content

The ScreenManager is a static class.
It allow the developer to control a NativeWindow through the following methods:
(incorrect signatures)

  • ScreenManager.centerWindowOnScreen()
  • ScreenManager.getActualScreenBounds()
  • ScreenManager.getScreenColorDepth()
  • ScreenManager.getVisibleScreenBounds()
  • ScreenManager.moveWindow()
  • ScreenManager.openWindowCenteredOnScreen()
  • ScreenManager.openWindowOnScreen()
  • ScreenManager.stretchWindowToAllScreens()
  • ScreenManager.stretchWindowOnScreen()
  • ScreenManager.openWindowFullScreenOn()
  • ScreenManager.setWindowFullScreenOn()
  • ScreenManager.moveWindowToCorner()
  • ScreenManager.openWindowInCorner()

and the following properties:

  • ScreenManager.mainScreenIndex
  • ScreenManager.numScreens
  • ScreenManager.maximumAvailableResolution

The ScreenManager can be downloaded here .

Posted in AIR, AS3, Flash, Flex.

Tagged with , , , .

Extending BulkLoader – Throwing an event when an item is downloaded

A while ago, I needed something that could load a LOT of images at a short times notice without Flash crashing or stopping in the middle of the queue without reason, like what happens if you loop a Loader 500 times.

Then I found BulkLoader…
It was all I needed, but then the client wanted the image added to the stage at the moment it was downloaded, this is not build in the BulkLoaders classes, so I extended those.

Here is how I did it.

Getting started

We are going to extend the BulkLoader classes so it throws an event when a single download has finished.
To do this, get the latest version of BulkLoader at Google Code.

Unpack the zipped file, and open up the and in the package.

Let’s start with adding an event constant name with the global variables:

public static const ITEMLOADED : String = "item_loaded";

You may insert it under the line (178):

public static const COMPLETE : String = "complete";

Next scroll down to the function _onItemComplete (line 801).
At the bottom of that function you should see the following if-statement:

 if(allDone) {

replace it with:

var eItemL : BulkProgressEvent = new BulkProgressEvent(ITEMLOADED,item);
eItemL.setInfo(bytesLoaded, bytesTotal, bytesTotalCurrent, _itemsLoaded, itemsTotal, weightPercent);
if (allDone) {

What did we do here?
We’re creating an instance of a BulkProgressEvent and add relevant information to it.
Next we’re going to dispatch it everytime this function is called.
As you can see, we’ve given the constructor another new parameter, the loaded item, we wil have to extend the BulkProgressEvent.

Start with adding a constant, a new name for a new kind of Event, an ITEMLOADED event, you can do that under line 52:

public static const ITEMLOADED : String = "item_loaded";

Next, create an new public variable (or an private one and make it a property by adding a getter & a setter), named lastLoadedItem (under line 70 for example):

public var lastLoadedItem:LoadingItem;

Now we are going to change the BulkProgressEvents constructor by adding a new parameter. Insert llItem:LoadingItem=null after the name parameter so the constructor looks like this:

public function BulkProgressEvent( name : String,llItem:LoadingItem=null, bubbles:Boolean=true, cancelable:Boolean=false ){

We gave it the default value null so we don’t have to change other code from the rest of the project.

Don’t forget to import LoadingItem


In the constructor, under the line = name;


this.lastLoadedItem = llItem;

Change in the clone function the line:

var b : BulkProgressEvent = new BulkProgressEvent(name, bubbles, cancelable)


var b : BulkProgressEvent = new BulkProgressEvent(name, lastLoadedItem, bubbles, cancelable)

And you’re done!
Now you can add an new eventlistener to you BulkLoader instance and capture every new loaded item.



Posted in AIR, AS3, bulkloader, Flash, Flex.

Tagged with , , .

Google API – AS3 Library

A while ago, I have build an API library in AS3 that interfaces with Google’s own AJAX API. To show you how performant this API is, I included a demo-app at the bottom of this blog.

The library is a simple collection of the API’s features, there is a class per feature, like Google Web search, Images Search, etc. Each library throws it’s own event with an Array of matching datatypes, for example GoogleWebItem, so it’s easy to keep track on wich data is recieved and what this data contains.

This api contains:

  • Google Web Search
  • Google Images Search
  • Google Book Search
  • Google Video Search (Google Video & YouTube)
  • Google Blog Search
  • Google Local Search
  • Google Patent Search
  • Google News Search
  • Google Translation
  • Google Weather
  • Google Suggest (new)

This API is Flash & Flex compatible.

Little example code

var googleWebSearch:GoogleWebSearch=new GoogleWebSearch(),0,lang)
private function onWebResults(e:GoogleSearchEvent):void{
   for each (var result:GoogleWebItem in as Array){
      trace(result.title, result.url)

The library

You can download the library here (updated).
The demo app can be found here.

Right-click in the app to see source-code.

Posted in AIR, AS3, BoulevArt, Flash, Flex.

FLVRecorder for Adobe AIR

FLVRecorder for Adobe AIR


When I was researching earlier this year whether or not I could capture a webcam feed and save it to the Flash Video Format, I stumbled on a guys blog called Zero Point Nine. He made a class that could save frames (BitmapData objects) passed to it as an FLV.

This was nice, but not very performant, as the parsing of the BitmapData to ByteArrays took way too long and was extremely CPU intensive and your app froze up, I decided to adjust the class and make it usable within an Adobe AIR app without losing a single frame, or freezing the app. For this, I started out with a new class, only copied the algorithms for writing an FLV and started building my own api.
The main target of developing this FLV-recorder was performance on the CPU and RAM side.



The purpose of this revolutionary new class is to record a stream of BitmapData to a FLV-file, because writing directly, and especially the converting-BitmapData-to-ByteArrays-with-byteshifting-part, made everything run shaky. I solved that issue by saving the BitmapData to a temporary file on the system. This to protect your RAM from overloading, and when done recording, the class converts that temporary file to an FLV-file.

For developing comforts, I build in a few events as well, when recording starts and stops, and an event while saving, with an indication of your progress.

The class offers the user to record via inputting BitmapData, Bitmaps and even your custom components, Flex component, like your VideoDisplay and also Flash components, like the FLVPlayBack or your custom Sprites and MovieClips.

The class does not yet support adding sound to the flv-file, this is the next step of development, to enable sound recording and add sound to the flv-file.


As a proof-of-concept, I built a small application that enables you to record your webcam and saved it on your desktop as an flv-file.

Screenshot of AirCam

Screenshot of AirCam

Download the AirCam installer here.
To view the source used in this project, right-click somewhere, and choose view source.

The FLVRecorder and all related classes are open source, they are not fully tested and may contain bugs.
I’m happy to share it with the community, use them, play with them and certainly enhance them!
These classes are NOT FOR COMMERCIAL USE and property of BoulevArt nv.

Download the source.


Posted in AIR, AS3, BoulevArt, Flash, Flex.

Tagged with , , .