header image
 

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

~ by brianchau on May 28, 2007.

3 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.

Leave a Reply