MultiResolution App

Hi guys,
This is my first thread on kirupa.com and i would like to thank to everyone contributing to that great forum.

Im working on a multidevice supported (multiresolution) project, however, changing the stage’s width and height properties on fly is not a supported feature of FlashPlayer if im not wrong. Therefore, the best solution could be to release several versions of your application for several range of devices. And not to dig in bunch of lines of code, u would hold static variables of the stage’s width and height, maybe in an enum class. And releasing would not beyond changing that values and ctrl+enter, viola!

Well, everything was pink until i build&run my project in adl(AIR). SWF metatag was saying 320480, and adl was set to iPhone predefined device profile, which is of 320480 as well. Most probably, with an adl device profile, metatag is ignored.

Anyway, as an AIR procedure, resizeEvent dispatced twice behind scenes, and after instantiating a starling object, twice more.


private var starling:Starling;
private var resizeTimes:int;
 
public function cmFormal():void
{
    stage.scaleMode = "noScale";
    stage.align = "TL";
    stage.mouseChildren = false;
 
    stage.addEventListener("resize", stgResizeHandler, false, int.MAX_VALUE, true);
    stage.addEventListener("deactivate", stgDeactivateHandler, false, 0, true);
}
 
private function stgResizeHandler(e:Event):void
{
    ++resizeTimes;
 
    if (resizeTimes == 2)
    {
        cmStarling = new Starling(cmMain, stage);
        cmStarling.showStats = true;
        cmStarling.enableErrorChecking = false;
        cmStarling.antiAliasing = 0;
        cmStarling.start();
    }
 
    if (resizeTimes == 4) {
 
        if (stage.orientation == "rotatedRight")
        {
            Enum.STG_W = Math.max(stage.stageWidth , stage.stageHeight);
            Enum.STG_H = Math.min(stage.stageWidth , stage.stageHeight);
        }
        else
        {
            Enum.STG_H = Math.max(stage.stageWidth , stage.stageHeight);
            Enum.STG_W = Math.min(stage.stageWidth , stage.stageHeight);
        }
 
        cmStarling.stage.stageWidth = Enum.STG_W;
        cmStarling.stage.stageHeight = Enum.STG_H;
 
        var viewPort:Rectangle = cmStarling.viewPort;
        viewPort.width = Enum.STG_W;
        viewPort. height = Enum.STG_H;
    }
}
 
  ///////////////////
 //application.xml//
///////////////////

/*
  <initialWindow>
    <visible>true</visible>
    <fullScreen>false</fullScreen>
    <autoOrients>false</autoOrients>
    <aspectRatio>landscape</aspectRatio>
    <renderMode>direct</renderMode>
    <systemChrome>standard</systemChrome>
    <resizable>false</resizable>
    <transparent>false</transparent>
    <minimizable>false</minimizable>
    <maximizable>false</maximizable>
  </initialWindow>
*/

WHAT I WANT TO KNOW:

  • After the latest(4th) ResizeEvent dispatced, the real/corrected values of STG_W and STG_H were 300*480, why, how to tackle?

  • How would you get corrected vals of STG_W and STG_H before an starling instantiation? because im holding these to use in my project, to get correct vals, i need to instantiate an Starling object.

AIR 3.5 | FP 11.5 | FD4.0.4RTM | The latest Starling frm GitHub