Firebase and AS3

Episode 3 : Queries and map drawing

Hi there. I hope you are well.

In the previous episodes, we have learned how to:

Episode 1: create different services and applications on Firebase, Google and Facebook

Episode 2: login with OAuth 2.0, retrieve user profile, write data on Firebase

In this last episode, we will see how to do queries and drawing a map in a Starling / Feathers application.


To make it working, we need a magic library: feathers-map.

Once again, I’ll do not tell you how to include a library into your project. This task is really easy.

The map screen

First we create a new screen for our application. And we put a map and a button on it.



Let me explain what we are doing.

On this new screen, we override the initialize method to put a title, draw a map and a button that call the next view.

We starts geolocation system on the phone with AIR runtime, and then adjust a few parameters.

Next, we make a Firebase Database REST API call to get all the markers that users sent. And finally, we draw them on the map.

Firebase and AS3 : Map and markers
Firebase and AS3 : Map and markers

The form screen

To enter data in our database, we need some kind of form. This one is the simplest I’ve found. Just a simple list which displays Pokémons names.

For the explanations, this is what we do:

First, we override initialize method to create a list and an event handler on item change.

Then, we create a query to write data into Firebase Database with REST API.

When data is on the server, then we go back to map screen.

Firebase and AS3 : Form
Firebase and AS3 : Form

Have fun

You can use everything in this tutorial. The code, the idea… Just have fun with it.

If you publish an application based on this few lines of code, do not hesitate to send me a message. I will be very happy to share it with my friends (who play Pokémon Go to). 😀

I encourage you to read again this part to be very fluent with Firebase Database REST API.

And… Rendez-vous in Episode 4 for a surprise.

PAY ATTENTION !! In fact, this is a very bad practice to incorporate your Firebase Secret Key in an application that can be easily decompiled (and SWF can be reversed). This exercise is just meant to show that use of the REST service firebase is possible from AS3. Acquire JWT from Firebase server (or your own server) remains the best option and can be easily achieved through a simple HTML page using the Web SDK Firebase and a WebView.