« ActionScript 3 Meets EXIF 2.1 | Main | Programmatic Skinning with Flex 2 »

December 02, 2005

Flash Lite 1.1 Inline Text

I attended Bill Perry's online seminar about Flash Lite the other evening on a whim. I've attended his seminar presentation before, and attended all the MAX 2005 Flash Lite sessions, but you just never know when you might see something new. Bill did a great job of covering an expansive amount of ground very succinctly. Towards the end he talked about some new components for Flash Lite that included inline text support. Go figure that I had just finished a project where I created such a component.

If you've developed with Flash Lite 1.1, then you know that inline text support isn't really supported. In its place, you have to open the device's text input mechanism. I've personally found this far too constraining for a number of reasons. First and foremost, it's the device's input mechanism (smile)! I want my application to have the feel of my application. Secondly is that in order to use the device text input, you must adhere to the focus mechanisms provided by Flash Lite and by that device. Quite frankly, if I can intercept directional events, I want to say where the focus will go next.

Then it occurred to me that if I can control where the focus is displaying, then I can certainly emulate text input by listening to the keypad events.

I started off implementing this to be as modular as possible such that I (or you) could easily reuse the "component" in other Flash Lite applications. I use a pixel font in my applications, and as such, my first step was simply to measure the characters that I was going to allow. Once I had the values, I hard-coded them into the component. When a character is entered, I know its width and can position a blinking cursor respectively.

This is an obvious limitation of the implementation, but the string of measurements can be easily changed for your own needs. However, you could do away with measuring altogether if you decided that you didn't want to present a highlighting or cursor mechanism. Is that poor UI design? Perhaps it is, but for the added flexibility, it might be perfect in some situations.

After being able to successfully append characters, and measure the presented value, I need to allow for characters that weren't the first on the button (e.g. "a" for the key-press of "2").

Following the convention of most mobile phones, I decided that I'd wait about a second before moving on to the next character. Since my application was running at twelve frames per second, it was relatively easy to setup a movie-clip timer. Before appending the newly entered character, I check the timer to see if it has returned to the first frame. If the timer is one the first frame, then I append the new value, and if the timer is somewhere in-between, I cycle through a range of possibilities.

Because I wanted to maximize reuse and modularity, I had to generalize the code. Abstracting the code to allow for various ranges forces a certain degree of complexity however, I’m certain that it’s still pretty readable. I've added a few subtleties such as checking to see if the character is first or follows a space, and then present case accordingly. The one thing I haven’t added is watching for a change in which key is being pressed, should the key-press occur before the timer is reset. This should be pretty minor to add however, I wanted to get this out as my last post as a Macromedia employee.

You can download the source and play around with it yourself, note however that I’ve not tested this on a phone as I *still* don’t have a phone that supports Flash Lite. If you do test it, and it works, I'd love to hear from you. Following is a Captivate recording of a sample application I built around the inline text component. It's got a little tongue-in-cheek humor given the recent announcements. The application also has a little Easter egg for your enjoyment (smile).



Posted by khoyt at December 2, 2005 10:20 AM

Comments

It works on my Nokia 6630 :)
nice Work

Posted by: Fabio at December 4, 2005 06:31 PM

Kevin:
Nice. Want to try this on my phone. And your email changed. Was wanting to see if i could talk you into showing me how to hook in the audio portion of the SRR tool. Have a great holiday and happy new year.
Craig

Posted by: Craig Newroth at December 21, 2005 09:49 AM

Nice. Want to try this on my phone. And your email changed. Was wanting to see if i could talk you into showing me how to hook in the audio portion of the SRR tool. Have a great holiday and happy new year.
Craig


http://beemoticones.en.wanadoo.es/
http://coemoticones.en.wanadoo.es/
http://osjeux.en.wanadoo.es/
http://tiajeux.en.wanadoo.es/
http://quejeux.en.wanadoo.es/
http://gujeux.en.wanadoo.es/
http://quejeuxx.en.wanadoo.es/
http://hojeux.en.wanadoo.es/
http://rajeux.en.wanadoo.es/
http://esjeux.en.wanadoo.es/
http://manjeux.en.wanadoo.es/
http://zajeux.en.wanadoo.es/
http://nasjeux.en.wanadoo.es/
http://tramusiques.en.wanadoo.es/
http://logomusiques.en.wanadoo.es/
http://cimusiques.en.wanadoo.es/
http://ermusiques.en.wanadoo.es/
http://tochansons.en.wanadoo.es/
http://eschansons.en.wanadoo.es/
http://hachansons.en.wanadoo.es/
http://bichansons.en.wanadoo.es/
http://dochansons.en.wanadoo.es/
http://tamchansons.en.wanadoo.es/
http://biparoles.en.wanadoo.es/
http://enparoles.en.wanadoo.es/
http://perparoles.en.wanadoo.es/
http://miparoles.en.wanadoo.es/
http://teparoles.en.wanadoo.es/
http://busparole.en.wanadoo.es/
http://carparole.en.wanadoo.es/
http://siparole.en.wanadoo.es/
http://alparole.en.wanadoo.es/
http://guiparole.en.wanadoo.es/
http://daecransveille.en.wanadoo.es/
http://soecransveille.en.wanadoo.es/
http://kuwallpaper.en.wanadoo.es/
http://cioalbum.en.wanadoo.es/
http://noalbum.en.wanadoo.es/
http://plalbum.en.wanadoo.es/
http://cartesamourr.en.wanadoo.es/
http://yecartesanimees.en.wanadoo.es/
http://tocartesanimees.en.wanadoo.es/
http://alcartesannivers.en.wanadoo.es/
http://gocartesannivers.en.wanadoo.es/
http://sicarteselectron.en.wanadoo.es/
http://micartesmusicale.en.wanadoo.es/
http://larcartesmusical.en.wanadoo.es/
http://cocartesnoel.en.wanadoo.es/
http://mocartesnoel.en.wanadoo.es/
http://sucartesnoel.en.wanadoo.es/
http://bitcartespostal.en.wanadoo.es/
http://porcartespostal.en.wanadoo.es/
http://locartespostale.en.wanadoo.es/
http://aecartespostale.en.wanadoo.es/
http://rocartespostales.en.wanadoo.es/
http://pucartespostales.en.wanadoo.es/
http://ercartesvirtuell.en.wanadoo.es/
http://toscartesvirtuel.en.wanadoo.es/
http://chicartesvirtuel.en.wanadoo.es/
http://cocartesvirtuell.en.wanadoo.es/
http://hazcartesamour.en.wanadoo.es/
http://mecarteanimee.en.wanadoo.es/
http://elcarteanimee.en.wanadoo.es/
http://recarteanniversa.en.wanadoo.es/
http://solcarteannivers.en.wanadoo.es/
http://vicarteanniversa.en.wanadoo.es/
http://mecarteelectron.en.wanadoo.es/
http://rescartemusicale.en.wanadoo.es/
http://picartemusicale.en.wanadoo.es/
http://rarcartenoel.en.wanadoo.es/
http://macartenoel.en.wanadoo.es/
http://dridcartenoel.en.wanadoo.es/
http://ducartepostale.en.wanadoo.es/
http://dascartepostale.en.wanadoo.es/
http://muncartevirtuel.en.wanadoo.es/
http://tocartevirtuelle.en.wanadoo.es/
http://tancartevirtuell.en.wanadoo.es/
http://vercartevirtuell.en.wanadoo.es/
http://revideocomiqu.en.wanadoo.es/
http://mevideodelire.en.wanadoo.es/
http://lenvideogag.en.wanadoo.es/
http://tovideohumoristi.en.wanadoo.es/
http://povideohumour.en.wanadoo.es/
http://covideoinsolite.en.wanadoo.es/
http://giavideodrole.en.wanadoo.es/
http://sevideos.en.wanadoo.es/
http://civideos.en.wanadoo.es/
http://onvideos.en.wanadoo.es/
http://beaudio.en.wanadoo.es/
http://nanaudio.en.wanadoo.es/
http://cioaudio.en.wanadoo.es/
http://locoaudio.en.wanadoo.es/
http://telechargercd.en.wanadoo.es/

Posted by: tuydes at March 28, 2006 12:13 AM

Post a comment




Remember Me?