2012-07-12 74 views
0

我做了一個全屏幕運行的Flash演示文稿,其中有幾秒鐘的動畫,然後開始播放視頻,當視頻結束時進入主菜單。我可以檢測顯示器是寬屏幕還是廣場屏幕?

視頻是720x1080(16:9),但我在Flash中的文檔是768x576(4:3)。 我根據768x576重新調整了視頻的大小,所以頂部和底部出現黑條。當我的Flash演示文稿在Square顯示器上運行時可以,如果顯示器很寬,該怎麼辦? 我想要「動作腳本」來檢測監視器的類型(寬或方形),如果它的方形保持視頻相同,但是如果監視器是寬的,則它以全屏方式開始視頻。

回答

2

您可以使用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

0

不完全在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