0

air in as3 を使用して、iPhone で mc を正確な画面サイズに設定しようとしています。

私は疲れました:

import flash.display.Screen;
import flash.geom.Rectangle;

var mainScreen:Screen = Screen.mainScreen;
var screenBounds:Rectangle = mainScreen.bounds;

/// Does not work - comes out 320 by 480
w.text = ""+screenBounds.width+"";
h.text = ""+screenBounds.height+"";
BG.height = screenBounds.height;
BG.width = screenBounds.width;

/// Does not work - comes out 320 by 480
w.text = ""+Capabilities.screenResolutionX+"";
h.text = ""+Capabilities.screenResolutionY+"";
BG.height = Capabilities.screenResolutionY;
BG.width = Capabilities.screenResolutionX;

/// Does not work - comes out 320 by 480
w.text = ""+stage.fullScreenwidth+"";
h.text = ""+stage.fullScreenHeight+"";
BG.height = stage.fullScreenHeight;
BG.width = stage.fullScreenWidth;


/// Works BUT... it does NOT stretch to fit the stage.
/// I am starting with android screen size and it shrinks it proportionally
/// which means there is space on top or bottom or left side.
w.text = ""+stage.stageWidth+"";
h.text = ""+stage.stageHeight+"";
BG.height = stage.stageHeight;
BG.width= stage.stageWidth;
4

4 に答える 4

1

それが320x480で出てきて、それが間違っていると言っている場合、iPhone 4Sを使用していると思いますか?その場合は、AppDescriptorXMLファイルに移動します。一番下(通常はファイルの最後の項目の1つ)に向かって、この行があるはずです。

<requestedDisplayResolution>standard</requestedDisplayResolution>

コメントアウトまたは「標準」に設定されている場合、これが問題になります。「高」と言うように変更すると、Retinaサポートが有効になります。「標準」は、非網膜ディスプレイ(iPhoneでは320x480、iPadでは1024x768)をスケールアップします。「高」は正しいディスプレイ解像度を提供します。

于 2012-09-15T00:15:57.970 に答える
1

stage.scaleMode をいじってみることができます:

stage.scaleMode = StageScaleMode.SHOW_ALL;

また

stage.scaleMode = StageScaleMode.EXACT_FIT;
于 2012-09-14T20:26:15.807 に答える
1

詳細な説明は次のとおりです。

http://www.adobe.com/devnet/air/articles/multiple-screen-sizes.html

于 2012-11-10T11:47:47.207 に答える
1

他の誰かが iOS の画面解像度の取得に問題がある場合。何が起こっているかというと、swf のロードが完了してから画面サイズを呼び出すまでに十分な時間がないということです。

私のアプリでは、画面サイズに対する相対値をパーセントで設定してすべてのクリップのサイズと位置を設定しているため、スケールのない swf が必要です。

私のステージが 800x1280 で、高さ = 100、幅 = 100 のクリップがあるとします。

次に、私の clips.height = int(stage.stageWidth * 0.125); と言うのと同じです。100 * 100 / 800 = 12.5; | | 100 は 800 の 12.5% です。

トリックは、最初のフレームの場合です(フラッシュを使用している場合)

ステージスケールを設定して、swf が完全にロードされるのを待つだけです。

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

var loadTimer:Timer = new Timer(10);
    loadTimer.addEventListener(TimerEvent.TIMER, loading);
    loadTimer.start();

function loading(evt){
    if(root.loaderInfo.bytesLoaded == root.loaderInfo.bytesTotal){
        loadTimer.stop();
        loadTimer.removeEventListener(TimerEvent.TIMER, loading);
        gotoAndPlay(2); 
        }
    }

次に、フレーム 2 で stage.stageWidth を呼び出すと、アプリがその値を取得するのに十分な時間を与えているため、実際のサイズが得られます。

var stageW:int = stage.stageWidth;
var stageH:int = stage.stageHeight;

役に立てば幸いです、ありがとう

于 2015-07-06T17:10:59.610 に答える