I have an Air/As3 app with a stage size of 1024x600 px auto scaled to fit a screen of 1280x720 px. When I request an admob ad (using an ANE) the ad width size reported is 320 (Standard Banner) but this size is based on DPI not in real pixel and I can not calculate x position to get it aligned to center of the screen. How can I get the real pixel width size of the ad?
Asked
Active
Viewed 728 times
1 Answers
1
The conversion from dp units to screen pixels is given by
px = dp * (dpi / 160)
as explained here
http://developer.android.com/guide/practices/screens_support.html
so does not matter if you are scaling the flash content as the admob ad does not care. To center the ad at the bottom of the screen you use this:
admob.addToStage((Capabilities.screenResolutionX/2)-(((admob.getAdSize().width)*(Capabilities.screenDPI/160))/2),(Capabilities.screenResolutionY)-((admob.getAdSize().height)*(Capabilities.screenDPI/160)));

Delcasda
- 371
- 4
- 13