我可以检测显示器是宽屏幕还是广场屏幕?

问题描述:

我做了一个全屏幕运行的Flash演示文稿,其中有几秒钟的动画,然后开始播放视频,当视频结束时进入主菜单。我可以检测显示器是宽屏幕还是广场屏幕?

视频是720x1080(16:9),但我在Flash中的文档是768x576(4:3)。 我根据768x576重新调整了视频的大小,所以顶部和底部出现黑条。当我的Flash演示文稿在Square显示器上运行时可以,如果显示器很宽,该怎么办? 我想要“动作脚本”来检测监视器的类型(宽或方形),如果它的方形保持视频相同,但是如果监视器是宽的,则它以全屏方式开始视频。

您可以使用Capabilities类,它有两个属性,screenResolutionXscreenResolutionY,它会给你这个信息。这给你主屏幕的分辨率。

您可能想要重新考虑一个监视器是正方形的假设。屏幕分辨率是4:3(640x480,800x600,1024x768,1280x1024),或者在我的宽屏幕显示器上显示一些其他比例,既不是4:3也不是正方形(1920x1080)。您可能想要对宽屏幕显示器使用的比率进行一些研究(笔记本电脑可能具有一定范围的值)。

您的代码应查询的Flash播放器的屏幕分辨率:

var screenWidth:Number = Capabilities.screenResolutionX; 
var screenHeight:Number = Capabilities.screenResolutionY; 

然后你可以决定在适当的时候切换到全屏或在常规尺寸(768×576)呈现视频。我可以想出几种方法来决定这一点,我相信你也可以。

下面是伪代码的一些想法,让你想为你的应用程序的适当的解决办法:

if screen is not 4:3, assume wide screen and use full screen 
if screenWidth >= actual width of video (1080), use full screen 
+0

你可以提供一个示例脚本吗? – ab8action 2012-07-12 07:37:36

+0

我在思考这个问题后编辑了我的答案。 – 2012-07-12 08:05:54

+0

我认为最简单的解决方案,我可以找到的是,有很多显示器正在进入市场与不同的决议像我的是1600x900 ....屏幕分辨率是不同的一家公司其他。 但有一点仍然是一样的:监视器是Square或Wide。 它只需要检测到这一点。我正在研究“功能”部分。 – ab8action 2012-07-12 12:15:54

不完全在ActionScript但以下是你的代码看起来应该像成绩单。

var nScreenWidth:Number = Capabilities.screenResolutionX, 
    nScreenHeight:Number = Capanilities.screenResolutionY; 

var nVideoWidth:Number = video.source.getWidth(), //assuming you are using video class, this should be video native size and not video component size. 
    nVideoHeight:Number = video.source.getHeight(); 

var nRatioX:Number = nVideoWidth/nScreenWidth, //Calculating X and Y ratio of video source and screen. 
    nRatioY:Number = nVideoHeight/nScreenHeight; 

var nRatio:Number = Math.min(nRatioX, nRatioY); //Picking up smaller ratio so that we can fit video in screen. 

video.width = Math.round(nScreenWidth * nRatio); //Set video component width and height, this should make it fit to screen keeping aspect ratio. 
video.height = Math.round(nScreenHeight * nRatio); 
+0

我不确定我的语言是否足够清楚地解释我想说的话。我希望我可以在这里粘贴图像。 – ab8action 2012-07-13 06:04:13

+0

你可以。你可以在一些服务器上传图像并给出路径... – DexTer 2012-07-13 13:28:13