2009-09-21 4 views
2

私はビデオプレーヤーを作成しましたが、クリックするとビデオをフルスクリーン表示モードにするボタンを追加する必要があります。私はステージ上のすべてのものをスケールすることは望まない。ビデオだけだ。私はこれを行う方法を見つけることができないようだ - 私はそれが簡単だろうと思った。as3ビデオフルスクリーンモード

答えて

1

私は、表示ツリーのルートでステージオブジェクトを効果的に拡大するので、要素全体を選択するのではなく、ステージ全体をフルスクリーンに設定することができます。探している効果を達成する最善の方法は、表示したくないオブジェクトを、FullScreenEvent.FULL_SCREENイベントハンドラで整列/非表示/表示することです。

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/FullScreenEvent.html

また、ステージのドキュメントから関連ちらほら、displayState section

フルスクリーンモードで動画のスケーリング動作は、ステージを使用してのscaleMode設定(設定によって決定されます。 scaleModeプロパティまたはSWFファイルの埋め込みタグ設定をHTMLファイルに追加します)。アプリケーションがフルスクリーンモードに移行しているときにscaleModeプロパティをnoScaleに設定すると、ステージの幅と高さのプロパティが更新され、ステージのサイズ変更イベントがステージングされます。これが動作するかどうか

2

参照:

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; 
+0

これは... ^^^ – samccone

0

ステージ上の要素はあなたが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 
    } 
} 
1

は最近、この問題に出くわし、これは魅力のように働きました。それで誰かを助ける場合に備えてここに置いてください。

Flexクライアントコード:

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) 
    } 
} 
0

... 
stage.displayState = StageDisplayState.NORMAL; 
... 

注意をフルスクリーンモードを終了するにはフルスクリーンモード

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; 
} 

を入力するには:あなたはまた、エスケープキーを押すことができます。

出典:?http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS44B1892B-1668-4a80-8431-6BA0F1947766.html

+0

正しいです。しかし、ここであなたがビデオプレーヤーのサイズを変更していません! – akmozo