ビデオ プレーヤーを作成しましたが、クリックするとビデオが全画面表示モードになるボタンを追加する必要があります。ステージ上のすべてを拡大縮小したくはありません。ビデオだけです。これを行う方法が見つからないようです-簡単だと思いました。
5 に答える
これが機能するかどうかを確認します。
stage.displayState = StageDisplayState.FULL_SCREEN;
videoPlayer.x = 0;
videoPlayer.y = 0;
//save the width and height in temp vars
//for restoring them later.
videoPlayer.width = stage.fullScreenWidth;
videoPlayer.height = stage.fullScreenHeight;
最近この問題に遭遇しましたが、これは魅力のように機能しました。だから、それが誰かを助ける場合に備えて、ここに置いてください。
フレックス クライアント コード:
private function startFullScreen(event:MouseEvent):void
{
videoHolder.removeChild(vid); //videoHolder is an spark VideoDisplay
Component
this.stage.addChild(vid);
this.stage.displayState = StageDisplayState.FULL_SCREEN;
oldWidth = vid.width; //store old values required while going back
oldHeight = vid.height;
vid.width = this.stage.width;
vid.height = this.stage.height;
this.stage.addEventListener(FullScreenEvent.FULL_SCREEN,fullScreenHandler);
}
}
/* handler for Fullscreen */
private function fullScreenHandler(event:FullScreenEvent):void
{
//This function is called when user presses Esc key
//on returning to normal state, add the video back
if(!event.fullScreen)
{
this.stage.removeChild(vid);
videoHolder.addChild(vid);
vid.width = oldWidth;
vid.height = oldHeight;
this.stage.removeEventListener(FullScreenEvent.FULL_SCREEN,fullScreenHandler )
}
}
私の理解では、表示ツリーのルートでステージ オブジェクトを効果的に拡大しているため、要素を選択的にではなく、ステージ全体をフル スクリーンに設定することしかできません。探している効果を実現する最善の方法は、FullScreenEvent.FULL_SCREEN イベント ハンドラーで表示したくないオブジェクトを配置/非表示/表示することです。
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/FullScreenEvent.html
また、ステージ ドキュメントのdisplayState セクションからの関連情報:
フルスクリーン モードでのムービーのスケーリング動作は、scaleMode 設定 (Stage.scaleMode プロパティまたは HTML ファイル内の SWF ファイルの埋め込みタグ設定を使用して設定) によって決まります。アプリケーションがフルスクリーン モードに移行しているときに scaleMode プロパティが noScale に設定されている場合、ステージの幅と高さのプロパティが更新され、ステージのサイズ変更イベントが発生します。
ステージ上の要素がスケーリングされている場合、ステージ オブジェクトにフルスクリーン モードになるように単に指示するのではなく、fullScreenRect プロパティを使用しているように聞こえます。
Amarghosh には適切なアプローチがありますが、リスナーをアタッチすることでより柔軟にすることができます。
stage.addEventListener(Event.RESIZE, _onStageResize, false, 0, true);
stage.displayState = StageDisplayState.FULL_SCREEN;
private function _onStageResize(event:Event):void
{
if(stage.displayState == StageDisplayState.FULL_SCREEN)
{
// Proportionally resize your video to the stage's new dimensions
// i.e. set its height and width such that the aspect ratio is not distorted
}
else
{
// Restore the normal layout of your elements
}
}
全画面モードに入るには
var fullScreenButton:Button = new Button();
...
addChild(fullScreenButton);
fullScreenButton.addEventListener(MouseEvent.CLICK, fullScreenButtonHandler);
...
private function fullScreenButtonHandler(event:MouseEvent)
{
var screenRectangle:Rectangle = new Rectangle(video.x, video.y, video.width, video.height);
stage.fullScreenSourceRect = screenRectangle;
stage.displayState = StageDisplayState.FULL_SCREEN;
}
全画面モードを終了するには
...
stage.displayState = StageDisplayState.NORMAL;
...
注: エスケープを押すこともできます。