Objective-C // Runtime Method Injection

While building our Actionscript Native Extensions we've had to learn a lot about Objective C for the iOS versions. One trick that we'd like to share is how to inject a method into an instance of a class at runtime. This is necessary for several of the extensions we've done and it took me a while to figure out how to do this so I thought I'd share.

Quick Links:

Continue reading Objective-C // Runtime Method Injection

Quick Android Notification Example

So we all know and love our Android notification bar. So I just wanted to post a quick example application to show how easy it is to display a local notification.

The process runs something like this:

  • retrieve a reference to the NotificationManager
  • create a Notification
  • notify the manager of the notification you've created

Continue reading Quick Android Notification Example

KML Loader Update

So as many people know, I've been promising an update to the KML Loader for a while now, and even to the point where I've had some local revisions and haven't had the time to check them in (I know, I know, bad practice!)

The major update has been to enable the ability to load linked assets. Initially this just extends to ground overlays and custom icons, but now that I have the structure setup to do this I'll be able to add in linked files and styles easily.

Continue reading KML Loader Update

Streaming Webcam To a Ubuntu Red5 Server

For an upcoming project we needed to stream content from the user's webcam to be recorded on the server. In theory this sounded like a basic operation, having used FMS to this end before, but actually installing and setting up the Red5 server proved to be a little tricky. So I just wanted to outline the process I went through to get a Red5 Server running on ubuntu and how to setup your first recording stream.

Red5 is a powerful Java based video streaming and multi-user solution for the Flash Player. Red5 includes support for the latest multi-user API’s including NetConnection, NetStream and SharedObject’s while providing a powerful RTMP / Servlet implementation. It is basically an open source Flash Media Server.

We're going to go through two major steps here, firstly installing Red5 on Ubuntu and then building a simple application to record the webcam.
Continue reading Streaming Webcam To a Ubuntu Red5 Server

Simple KML Loader Revisited

Recently we've been using some of our own tools in other projects and found some room for improvement on the KML Loader we developed. In particular we wanted a simple class that could handle all the processing from the loader, adding the resulting overlays to the google map. Also we needed it to load in some of the styles, such as colours and line types.

Example Kml Loader ScreenShot

So we've expanded our KmlLoader class and provided a few additional utility classes.
Continue reading Simple KML Loader Revisited

Simple KML Loader

Lately we have been playing around a fair bit with some google flash maps and have been amazed by the power and simplicity of the API. We used it heavily in the ABC Black Saturday site using custom markers with images and even a scrolling grid.

We were faced with another challenge of being able to mark out areas (districts) within Victoria that represented the most affected regions. These regions were sometimes complex and we needed to be able to update them simply and quickly as the need arose. The regions weren't to be displayed directly but used for two major items. Firstly to focus the map on a particular region, by moving the view to the region contained by these districts, and secondly, to assign events/markers to a district by calculating if they were contained within the bounds of the district lines.

The solution ended up being ridiculously simple. We created a shared map on google maps, with shapes defining the districts. We then could export from this online map to kml by grabbing the view in Google Earth link and changing the output parameter from nl to kml. This gave us the map of the districts in a nice kml format.

abc-district-google-map

Once we had the map in kml we needed to load in the objects and create overlays for google maps. Surprisingly there wasn't a simple "load kml" function in google maps, but there are some nice kml parsing utilities in the google map extras library. So we created a kml loader class that loads the kml file, extracts the objects and creates overlays for placement on a google map. Hopefully it can be helpful to others, check it out from the following:

https://github.com/marchbold/as3-gmaps-utils

Usage:

Firstly create the loader and start the load of your kml file. You'll need to add a listener to the COMPLETE event to process the code on completion.

  1. import com.distriqt.gmaps.kml.utils.*;
  2.  
  3. var kmlLoader:KmlLoader = new KmlLoader();
  4. kmlLoader.addEventListener( Event.COMPLETE, kmlLoader_completeHandler );
  5. kmlLoader.load( "your-kml-file-location.kml" );

Once the loading is complete you'll have to re-curse through the object list in the loader, adding the objects to your map. Note the "map" variable in the below should be your google map instance.

  1. function kmlLoader_completeHandler( _event:Event ):void
  2. {
  3. for each (var _object:KmlDisplayObject in KmlLoader(_event.currentTarget).objects)
  4. addObject( _object );
  5. }
  6. function addObject( _object:KmlDisplayObject ):void
  7. {
  8. // It may just be a container with child elements
  9. // so check if there is an overlay
  10. if (_object.overlay != null)
  11. {
  12. // Here you can add the kml object to your map
  13. map.addOverlay( _object.overlay );
  14. }
  15. // Add the children
  16. for each (var _child:KmlDisplayObject in _object.children)
  17. addObject( _child );
  18. }

Let us know if you find it useful.