Auto-Resize of Flash Lite application

I was asked recently by a mobile content developer if Flash Lite app can auto-resize based on the mobile phone screen orientation. Some mobile phones come in landscape mode, others come in portrait mode. Then there are also phones like the Treo that have square screen. And that is not all, some phones like i-mate JASJAM can change the screen modes (portrait/landscape) when the keyboard slides in and out. So does that mean we have to create different versions of the same app for these different phones? Answer is no. Flash Lite app can detect screen orientation on app starts up and when the screen orientation changes. See below code for an example:

// To respond to landscape, portrait and square viewing
Stage.scaleMode = “noScale”;

var stageListenerObj:Object = new Object();
stageListenerObj.onResize = function () {
    if (Stage.width > Stage.height){
  gotoAndStop(“landscape”);
 } else if (Stage.width < Stage.height) {
  gotoAndStop(“portrait”);
 } else {
  gotoAndStop(“square”);
 }
}

Stage.addListener(stageListenerObj);

Download the Flash Lite player for Nokia S60 series phone and Windows Mobile phone here

Advertisements

~ by brianchau on May 28, 2007.

5 Responses to “Auto-Resize of Flash Lite application”

  1. I suggest before you post code online, you check if it works! It you have a big mistake: instead of “} else if (Stage.width > Stage.height) {” you need to say “} else if (Stage.width with a < because portrait means width < height

  2. […] landscape and portrait mode. There is a nice code snippet here, but there is a big boo-boo in: Auto-Resize of Flash Lite application watch out for that else statement, it should be else if […]

  3. Oops. Thanks for pointing out the typo. Yes, it should bethe smaller than sign, not the bigger than sign . My mistake. Now updated on the page.

  4. Thanks for the tips.
    I want to ask you what is the best workflow if I have convert a windows flash content for mobile device?

  5. Rvk,it depends. While a desktop flash application can be scaled to fit the screen of the mobile, it may not be the best to have evrything cramped into a small screen. I always feel that we should design with a target medium in mind. What looks good on a 15 inche display may not necessarily be good for a 3 inch display.

    If you have an existing desktop flash file, you may want to first convert the app based on the device profile that we are targeting. Then publish the content to test it in device central and see what needs to get changed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: