Skip to main content
Participating Frequently
February 8, 2012
Question

iPad: Centering the application (StageAlign.TOP_LEFT isn't)

  • February 8, 2012
  • 1 reply
  • 977 views

So I have an application that I want to be full screen and centered.

Most of the codebase is done via Flash Pro and then exported as a swc that's imported into a Mobile Actionscript Project in Flash Builder.

So far, so good.

Here's the constructor for main class of that project:

        public function myApp()

        {

            super();

            stage.align = StageAlign.TOP;

            stage.scaleMode = StageScaleMode.NO_SCALE;

            var t:MovieClip = new Game(stage) as MovieClip;

            addChild(t);

        }

Here's the issue:

Despite the fact that the original stage size is 1024 x 750, I cannot get that object to line up with the borders of the emulated ipad without moving it (e.g. when using left I have to offset it on y by -185 or so pixels).

StageAlign.TOP_LEFT is the closest, but it's about 20 pixels too far "up."  Wherever the application decides that 0,0 is is entirely dependent on what alignment I use.

I can't simply offset the myApp object, nor the Game object, as it completely screws with the X and Y values of some objects (i.e. mouse events as well as localToGlobal).

(Also, I have to set StageScaleMode.NO_SCALE or the application ends up far too LARGE for the ipad's screen, by almost double).

I've also tried some of the settings in the *-app.xml file, to no avail.  In fact, attempting to force a min size equal to the application's actual size causes it to vanish completely and setting an X and Y position appears meaningless.

What gives?

This topic has been closed for replies.

1 reply

Colin Holgate
Inspiring
February 8, 2012

If you're saying that you want the stage to scale to fit the screen, and be centered, then just take out all of your stage scale and align code. Without any of that in there the stage will scale to just fit inside the screen, and will be centered.

Draco18sAuthor
Participating Frequently
February 8, 2012

Except that that doesn't work either:

Note how it's too large (by almost double) and the top edge of the main object is, oh, 185 pixels below the top of the iPad.  Rotating the iPad doesn't solve the issue.

Colin Holgate
Inspiring
February 8, 2012

To get that screenshot, what remaining scale and align code do you have? What x and y values are you using for the game movieclip?