Quick and Dirty Skinning of a Flex Mobile Button

I’m working on a mobile project and trying to implement based on a beautiful design comp. Unfortunately I haven’t had a lot of luck finding out how to do this right… So I’ll tell you how I did it, right or wrong.

So I start off with the design comp.  This is what I want to achieve: 

First, I create a blank skin that extends spark.skins.mobile.ButtonSkin.

The mobile skins use an image named “border” to render the border of the button. I’ll exploit that to show the new background image of my skin. There are two images for mobile skins: an up and a down. The Button has a function to return, which should be the correct image for either the up or down state… so:

I import new background images to replace the default up and down backgrounds of the button.

http://snipplr.com/js/embed.js
http://snipplr.com/json/54891

I override the getBorderClassForCurrentState function. (I’m also changing the font color here on the down state, probably the wrong place to do it but it works.)

http://snipplr.com/js/embed.js
http://snipplr.com/json/54892

This will yield this result:
 

It’s using the background but it’s small, so I hardset the size in the constructor.

http://snipplr.com/js/embed.js
http://snipplr.com/json/54893

This is a big no-no when it comes to mobile development, as that doesn’t scale to many screens well. But my app is pretty specific and I can get away with it.

This yields:

Good, but I need to remove the background shape. I do this by overriding drawBackground and setting it to do nothing.

http://snipplr.com/js/embed.js
http://snipplr.com/json/54894

Which yields this:

Finally I need to set the fonts. Mobile buttons have drop shadows on their text, but they don’t render using an actual dropshadow filter; they do it by having a second textfield behind the first. So I need to alter and tweak that font to the same settings by overriding the labelDisplay_valueCommitHandler.

http://snipplr.com/js/embed.js
http://snipplr.com/json/54895

And there you have it, a custom skinned button in Flex Mobile. If anyone sees glaring problems with this let me know.

Here’s the entire source if you are interested.

http://snipplr.com/js/embed.js
http://snipplr.com/json/54896

NY Flex User Group and Flash and the City 2011

I’ll be in New York next week doing two events:

NY Flex User Group
Tuesday June 7th 2011
Razorfish: 1440 Broadway 18 Flr. New York, NY 10018
Register
I’ll be talking about the Flash Builder 4.5 and Flex 4.5. But I’ll also touch on some of upcoming features of Flex and Flash Builder and showing off a few cool new mobile projects.
Flash and the City
Thursday June 9th 2011
Find out more
I’ll be talking about ColdFusion, what’s currently going on with it, and why you would want to use it as a Flash Developer.

Creating Mobile Application Icons with Fireworks

One of the many issues you have to manage when creating mobile applications is the myriad number of icon sizes you have to deal with. There’s a great summary of them at SavageLook.com.

As a developer, your first instinct is that there has to be some way of automating this. In fact, one of my coworkers, Piotr Walczyszyn has created one of these.

The difficulty with this approach in my opinion, is that you end up with suboptimal icons. For my current cross screen applications, I need to make icons that range in size from 512×512 pixels, to 29×29 pixels. The automatic approach will have you create an icon at 512×512 and size down to each size you need until you hit 29×29 pixels. But 512×512 is so much more room to work with. You could add extra text, more graphics, or detail. At the other end, 29×29 is so small, words aren’t able to fit and be legible. Often you want to just have initials or one letter. Often you have to change the font to make it legible at that size even for one letter.

The best solution would be to have individual files for each icon. But that seems like a lot of pain. I’m sure people do it. I’m sure I do not want to be one of those people.

So I want to have one file I need to edit to create my icons, I want to be able to have multiple resolutions of icons, and have each one be different, if needed. But I’d also like to just cut and paste and resize if need be.

My solution: Fireworks and slices. I made a template that has guides for all of the icon resolutions that I currently support. I added in slices, and named them to get good file names via the export. Then I just export the slices to get the icon files.

To use:

  • Download the template
  • Place all your icons on the template
  • Chose File -> Export from the menu
  • Change Export to “Images Only”
  • Deselect “Include Areas without Slices”
  • Export

 

Now I have one file to tweak when I have to tweak icons. I can tweak all of the icons separately. I can get all of the icons out in one export command. Exactly what I wanted, good and fast.

Let me know if the template helps you guys out at all.

Flex Media Queries for BlackBerry PlayBook

A cool feature now in Flex is media queries. Media queries allow you to deliver different CSS, depending on either the device OS or the pixel density of the device. This is very useful for tweaking your apps to work with the different standards for UI across devices.

Here’s an example. It changes the appearance of Flex menus on iOS, to make the look more iOS’y.

http://snipplr.com/js/embed.js
http://snipplr.com/json/54386

The relevant docs mention:

  • Android
  • IOS
  • Macintosh
  • Windows
  • Linux

But there’s no mention of BlackBerry PlayBook. After a little digging, I found this tidbit in the original sdk docs.

os-platform (allowed values are “Android”, “IOS”, “Macintosh”, “Windows”, “Linux”. Other values are allowed and will be matched against the three character platform abbreviation in Capabilities.version in case new platforms become available).

Which means the example below totally works for BlackBerry PlayBook.

http://snipplr.com/js/embed.js
http://snipplr.com/json/54387

Toddler Timeout

My first full fledged mobile app is now on the Android Market.

It’s called “Toddler Timeout!” and it’s got real world uses. If you do the whole timeout thing on your kids, this is a timer for doing that when you’re on the go. That’s right, discipline for your child ANYWHERE!

My plan is to release it on the Android Market first, use the easy to publish nature of the Android Market to iterate over all of the bone head bugs I’ve left in it. I’ve also submitted it to the Amazon App Store too. It’s awaiting approval.

Then once I’ve stabilized it, I’ll get it on to submit it to the BlackBerry and IOS stores.

A couple technical things about it:

  • It uses Flex
  • The timer is a Flex MX PieChart
  • I minimally performance tuned it

Expect a few blogs posts around it soon.

Go give it a shot. Toddler Timeout!

Motorola MOTODEV App Summits – South American Leg

A few weeks back I announced that Adobe would be participating in Motorola’s MOTODEV tour featuring the XOOM and ATRIX. Mark Doherty and I will be talking at multiple events with Motorola.

I’m pleased to tell you we have confirmation on dates for the South American (and Central American) leg of the MOTODEV tour.

Beijing, China – April 26 (Mark)
Shanghai, China – April 29 (Mark)
Sao Paulo, Brazil – May 16 (Terry)
Buenos Aires, Argentina – May 19 (Terry)
Mexico City, Mexico* – May 23

Can’t wait.

Building Mobile Apps for Multiple Devices with Flex at 360|Flex

It looks like I never got a description into the good folks at 360|Flex about my session. Sorry about that.

Building Mobile Apps for Multiple Devices with Flex

Building apps for multiple devices isn’t just as simple as redoing your existing apps in Flex Hero, and running Export Release Build in Flash Builder. Getting applications to work on multiple screen takes thought and work in:

  • Design
  • Coding
  • Configuration
  • Packaging

 

The session will cover topics including:

  • Application DPI
  • Mobile Design
  • Simulating various Screens
  • MXMLC
  • Command line packaging
  • ANT
  • Publishing for multiple stores
  • and more

 

It’s a high level exploration of these issues, and will touch on content that is addressed deeper in other 360|Flex projects.

It’s time has also been changed from the paper schedule. It will take place:
Monday at 10:50 AM in Salon C.

Motorola MOTODEV App Summits Tour!

I’m pleased to announce that Adobe is participating in Motorola’s MOTODEV App Summits. The App summits are designed to bring developers up to speed in developing Android Apps for Honeycomb, specifically focused on the XOOM with Honeycomb OS, as well as for smartphones like the ATRIX.

I’m also pleased to announce that Mark Doherty and I will be giving sessions on AIR for Android development at these events.

Berlin, Germany – April 11 (Mark)
London, UK – April 15 (Mark)
Beijing, China – April 26 (Mark)
Shanghai, China – April 29 (Mark)
Seoul, Korea* – May 2
Sao Paulo, Brazil* (Terry)
Buenos Aires, Argentina* (Terry)
Mexico City, Mexico* – May 25

If you’re near any of these cities and eager to get your Honeycomb on, or just to check out the cool stuff Motorola’s got going on, please come on down. Register at the MOTODEV App Summit website.

Getting Started with PlayBook Development Links

As collected by my colleague Renaun Erickson, here’s a whole bunch of links to get you started with BlackBerry development.

Main Landing Page for all BlackBerry Tablet OS SDKs
http://us.blackberry.com/developers/tablet/

BlackBerry Tablet OS SDK for Adobe AIR
http://us.blackberry.com/developers/tablet/adobe.jsp

BlackBerry Developer Forums
http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/bd-p/tablet

BlackBerry Issue Tracker (jira based)
http://us.blackberry.com/developers/resources/issuetracker/

On the Adobe side the go url is:
http://www.adobe.com/go/bbtabos

Some hot topics:
Uploading Your Playbook App to Blackberry App World
PaymentServices
QNX and MXML
Using ImageCache