2

我已经创建了一个视频播放器,但需要添加一个按钮,单击该按钮时,会将视频置于全屏查看模式。我不想缩放舞台上的所有东西——只是视频。我似乎无法找到如何做到这一点 - 我认为这很容易。

4

5 回答 5

2

See if this works:

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;
于 2009-09-22T13:37:08.920 回答
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 )
    }
}
于 2014-04-02T15:32:39.093 回答
1

我的理解是,您只能将整个舞台设置为全屏,而不是有选择地设置元素,因为您正在有效地放大显示树根部的舞台对象。完成您正在寻找的效果的最佳方法是安排/隐藏/显示您不希望在 FullScreenEvent.FULL_SCREEN 事件处理程序中可见的任何对象。

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

此外,来自 Stage 文档displayState 部分的相关花絮:

全屏模式下影片的缩放行为由 scaleMode 设置确定(使用 Stage.scaleMode 属性或 HTML 文件中的 SWF 文件的嵌入标记设置进行设置)。如果在应用程序转换到全屏模式时将 scaleMode 属性设置为 noScale,则会更新舞台宽度和高度属性,并且舞台会发生 resize 事件。

于 2009-09-22T01:53:53.267 回答
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
    }
}
于 2009-09-24T06:58:06.043 回答
0

进入全屏模式

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

注意:您也可以按 Escape。

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

于 2015-11-13T19:22:42.063 回答