Skip to content


as3flobile extension: as3flobile-android

I just made an initial commit to github with an as3flobile library extension named as3flobile-android.

as3flobile-android

The intent of as3flobile-android is to provide custom skins and controls that target the look-and-feel of the Android platform. Currently within the library are graphic assets, custom skins and a few *convenience* controls which are composite controls that extend their as3flobile counterpart with the skinning already wired up (take for instance the AndroidScrollList which extends ScrollList to provide custom item renderers and skins that have the look-and-feel of the Android list – also has the precense of scrollbars on scroll behaviour!).

Now, it should be said, i didn’t go all out and study/push every pixel to make the skins look *exactly* like Android. I just cut some graphics from a PSD and applied them in the skins. This is a project (of many) that i do on my spare time and if/when i do need to have themed rolled in for a paying client, i am sure a designer wold be breathing down my neck :) That said, If at the very least, it will provide an example to anyone who is interested applying custom skins to as3flobile components.

It should be noted (as it also is in the README markdown for the as3flobile-android repository) that I cut the graphics from a PSD made available by Pavel Macek. That PSD can be found at http://www.matcheck.cz/androidguipsd/ so check it out. The library also includes the ScaleBitmap from bytearray.org, available at http://www.bytearray.org/?p=118 and is pretty awesome. I made a slight modification to the source in order to re-use graphics in the skins (details can be found in the CHANGES document) so i could not have it external and compiles against.

There are a few more custom controls targeting the Android platform that i have yet to check in as i would like to drum up some examples before then. These include things like a ContextMenu, AlertDialog, TitleBar, etc. And most likely the Menu control from as3flobile will be moved to as3flobile-android as it really is Android specific… so look out for that.

Criticism and feedback is always welcome.

Posted in Android, Flash, as3flobile, as3flobile-android.


3 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. jerry says

    hi Todd,

    thanks for this Android version, really cool stuff :) .

    I managed to add a scroll list and to listen to the short and long press signals, but how can i change the background color of a cell when long pressed? That is not built in, right?

    I cannot even find where in your code you change the color at a short press, so i hope you can guide me a little,

    thanks,
    Jerry.

  2. todd anderson says

    HI Jerry,

    A scroll list (and the AndroidScrollList) have their mouseChildren property set to false by default to allow for better scrolling. When a tap (mouse down) event is picked up, it finds the associated item renderer at the index within the scroll pane and sets that renderers skinState property to BasicStateEnum.SELECTED, which in turn triggers the skin to update.

    If you look into AndroidListItemRendererSkin you will see how the background is updated based on state. That said, you are correct that there is no corresponding state for when an item is long-pressed.

    You can however get around this by providing a handler to the longPress signal of an AndroidScrollList, grab the item renderer from getRendererAt() and update its skin state.

    I made a quick example on how this would work that can be found at http://custardbelly.com/downloads/LongPressTest.zip

    In that example, i just grab the renderer in question and update its state to SELECTED when long-press is detected, then switch the state back to NORMAL when the menu is closed.

    If you want to get fancier with the selection displays (different color for long-press than the one used for SELECTED state), you would go about creating a custom item renderer and corresponding skin and supply that as the item renderer class for the list.

  3. jerry says

    thanks a lot for your quick reply and example, Todd.

    It works very well.
    Would it be hard to make it similar to the android interface, in that the long pressed item gets another background right from the moment you start pressing it instead of when the long pressed signal is being dispatched,
    and at the same time deselect a previously tapped item – and its background?

    Btw,the height of the context menu is now fixed on 160.
    Shouldn’t it be better to make that dynamic depending on the number of items?

    thanks again,
    Jerry.



Some HTML is OK

or, reply to this post via trackback.