Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8003159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:35:04+00:00 2026-06-04T16:35:04+00:00

EDIT: See also next question on Stackoverflow: Flash builder Mobile AS3 project: Screen DPI,

  • 0

EDIT: See also next question on Stackoverflow:
Flash builder Mobile AS3 project: Screen DPI, Application DPI, image DPI, center image

It has something to do with DPI settings…….


I want to center a DisplayObject to the center of the screen. This is an image dynamically created from a resource. I use the the following code to center the object after it is created:

public function showProgress(bValue : Boolean = true):void
{
  this.imgProgress.visible = bValue;
  if( bValue )
  {
    this.imgProgress.x = (this.stage.stageWidth - this.imgProgress.width) * 0.5;
  }
}

Looks quite simple to me but the object is still not in the center. For example:

this.stage.stageWidth == 500;
this.imgProgress.width == 480;
Result is: 10px; (this.imgProgress.x) /* 10px is correct */

I tried several things, also with localToGlobal and GlobalToLocal but getting unpredictable results, still not centered.

I think it has something to do with the screen dpi or something? But the Capabilities.screenDPI returns strange results. For example, running as iPhone 3GS it returns 163dpi.

How do i calculate the correct center position?

EDIT:
Some extra info:

public class Main extends Sprite
{
// setup stage
this.stage.color = 0;
this.stage.align = StageAlign.TOP_LEFT;
this.stage.scaleMode = StageScaleMode.NO_SCALE;

imgProgress is a child of this.stage

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:35:06+00:00Added an answer on June 4, 2026 at 4:35 pm

    It has something to with the aspect ratio (when calculated you are able to center it correcly)

    See also:
    Set ApplicationDPI in AS3 Mobile application

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Intro: EDIT: See solution at the bottom of this question (c++) I have a
EDIT: See my answer I saw some interesting frameworks to build applications for mobile
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
EDIT: I see why it doesn't run twice. I have the Ajax.BeginForm() call inside
I have a Controller with two Edit methods (see below). When I submit the
PLEASE SEE THE EDIT BELOW, THE REPORT SEEMS TO USE CACHED DATA? I cant
EDIT: You can see the search box live here . Before I explain, let
See updated input and output data at Edit-1. What I am trying to accomplish
[EDIT: Problem solved. Please see my answer below.] In my app I call the
EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.