Twitter: raymondcamden

Address: Lafayette, LA, USA

INeedIt - Simple Flex Mobile example

05-14-2011 9,435 views Mobile, Flex 13 Comments

I've been wanting to get back into Flex Mobile ever since the release of Flash Builder 4.5. Now that it's out - and now that I'm past cfObjective, I thought I'd whip up a quick demo. I still need to - you know - actually read up the docs a bit. What follows is... rough... but when it works it's kinda cool and I think it's a cool idea. Flex users please feel free to rip me a new one and help me improve the code.

A few days ago Google released an official public API for Places. The API allows you to get information about certain types of businesses based on location. So you could say, find me all the banks next to long/lat and within so many meters. Once you got the results, you could then get details. I noticed that quite a few types were supported by the API. I thought it might be cool to create a simple application that...

1) Finds out where you are using Geolocation

2) Provides a list of everything Places supports

3) Let's you pick one and then load the results

4) Let you pick a place to get details and call them.

Simple enough, right? Here's what I came up with. Note that I'm using screen shots from the emulator which does not support GPS. That's kind of silly I think. I'd love to see it updated to simply mock GPS info.

Once you select a category, like bar, you get a list of results:

And once you click a record, I can show the address, phone number, and a map.

So - here's some issues I'd love some help with:

  • The list view on my phone is too small. In the simulator it looks perfect. How can I make my list items fatter?
  • GPS is ... weird. The Geolocation API is an event handler. Every time the GPS updates it can fire a function. I only need one GPS reading though. But get this. It always reads Lafayette even though I'm in Minneapolis. If I let it run 2 or more times it correctly updates. But when I run the app again it goes right back to Lafayette. It's like it considers Lafayette as home and doesn't refresh it.
  • The Google Map, as you can see above, is a bit ugly. I'm not sure why. It should be higher quality. I assume I'm using the Image component poorly.

And with that, some random other notes:

  • The phone number is clickable. Try it. How could I style that to make it more obvious? Perhaps make it a button with the label being the number?
  • I'm supposed to add a credit logo for Google. I'll add that before I send this to the market. There's also random items for each place you are supposed to add for attributions. I'll need to add that too to be 'legit' with the API.

Ok - so I've attached one zip to this blog entry. The zip has 3 things in it. First is the FXP. If you have Flash Builder, you can import it. I also included a general zip of the project. That's for those of you without Flash Builder, or those who just want to use a text editor to look at the code. Finally, I included the APK you could - in theory - use to install on your phone. My app isn't signed so you will need to allow for that.

Download attached file

Related Blog Entries


  • Aaron DeRenard #
    Commented on 05-14-2011 at 11:09 PM
    Moved the apk over to my Incredible, used astro to find it, opened it with App Manager, hit Install and click Open when it was done installing... Menu appears, but nothing seems to be found.

    Back out of app, turn on standalone GPS, launch app... Works!

    Unfortunately the Places API looks like it doesn't find much of anything where I live (though it should) but some items are coming up and that's awesome! For instance, I would expect Gas Station to show at least 4 entries that are very close to me, but it doesn't show any. But it will show a cemetery that is quite further from me. One store that is next to another, but the other doesn't show (a local store shows, but CVS does not... strange [and I can't say what kind of store CVS is, because my comment gets flagged as spam]).

    So what I am trying to say for other readers that try the app out, don't just assume it isn't working after trying 4 or 5 menu items. Try a bunch because it's probably working, just the api isn't returning much. At least that's how it seems to me.
  • Commented on 05-15-2011 at 12:55 AM
    I would recommend you to use the Stagewebview to load maps as Chris did it I have compiled to iphone 4, ipad and android and works smooth!!
  • Commented on 05-15-2011 at 2:52 AM
    That's so cool. I've been looking forward to this post ever since you posted your intention on Twitter. Did it take you an hour, like you said? :D
  • Commented on 05-15-2011 at 5:41 AM
    @Aaron: I thought I had correctly accounted for both GPS not being available and being off - but I may have missed the 'just being off' part. I've got 3 hours in a layover today so can fix it then. ;)

    And yeah - the Places API doesn't have everything for sure.

    @Ivan: Thank you - I will try that.

    @Mihai: I'd say it took me 3 hours. I spent an hour after the conference and 2 hours after dinner. Forgot that I had never gotten my phone just right on the laptop (driver wise) so that was a hiccup.
  • Aaron DeRenard #
    Commented on 05-15-2011 at 9:06 AM
    @Ray: If I turn off Standalone GPS and Google Location Services, the app just sits on a "Getting your location..." state. If I just turn on Google Location Services, the same cemetery etc is found. So apparently last night was a hiccup in Google Location Services.

    So in short, it works fine with Google Location Services and/or Standalone GPS. And the "just being off" part may have been missed as you said.

    3 hours? Heh... Good job! I'm impressed.
  • Commented on 05-16-2011 at 7:12 AM
    I got a chance to test my app back in Lafayette yesterday. While in the airport, Google Places didn't know an airport existed. But it did find nearby restaurants when I picked food. Very cool to see this working.

    Also - I forgot to give credit to the AIR Launchpad ( It helped me write the GPS stuff and helped me with the splash screen syntax.
  • Commented on 05-16-2011 at 9:54 AM
    I've seen that geolocation issue on my Nexus One (not sure if it's a device issue or not) but I can assure you it's not anything related to AIR as I have seen it on a number of native apps as well.

    You can customize the list item appearance using item renderers. For performance purposes it's generally recommended you use ActionScript item renderers rather than MXML. Nahuel Foronda has a great multipart tutorial on it - here's part 1
  • Commented on 05-16-2011 at 9:56 AM
    Interesting - are you saying I need to do an item renderer just to make the items 'fatter'? Can't I do it via CSS or some such? I know writing item renderers isn't a big deal but it seems like overkill for this, doesn't it?
  • Commented on 05-16-2011 at 10:04 AM
    Appears so. Halo had a rowheight attribute on the List but Spark does not appear to have that. It might be possible with a skin rather than an itemrenderer but I'm not 100% certain (scanned the source with a coworker and saw minheight and maxheight attributes, so that might solve your use case...didn't see a fixed height setting though)
  • Commented on 05-16-2011 at 10:08 AM
    I'll give that a shot then. Could be a good blog post. What's odd though is that in the simulator it seemed perfect. I know the simulator is much bigger, but in "relation" to the chrome it was bigger. Does that make sense?
  • Commented on 05-17-2011 at 11:20 AM
    Posted my size/proportion question to Stack Overflow. First time I actually posted a question:
  • Commented on 08-08-2011 at 5:06 PM
    Can you provide us with the project file?
  • Commented on 08-08-2011 at 5:09 PM
    The most up to date code may be found here:

Post Reply

Please refrain from posting large blocks of code as a comment. Use Pastebin or Gists instead. Text wrapped in asterisks (*) will be bold and text wrapped in underscores (_) will be italicized.

Leave this field empty