2010-09-16 40 views
1

在我的Flex應用程序中,模塊可以大於屏幕分辨率並具有垂直滾動條。如何獲取屏幕上的可用區域

當用戶點擊某處時,我在鼠標座標的位置彈出一個小組件。

但是,如果用戶點擊太靠近屏幕的邊緣,我需要防止組件出現在可視區域之外。

爲此,我需要知道可視區域的尺寸。我嘗試了Capabilities.screenResolutionX和Capabilities.screenResolutionY,但他們這個區域將包含瀏覽器工具欄。

This.width和this.height顯然不會工作,因爲模塊的高度會超過100%。

那麼有什麼辦法來計算瀏覽器中的可用空間(無論是在動作或JavaScript)?

回答

1

我在Javascript和ExternalInterface中使用以下內容來檢索Actionscript3中的結果。

 
function pageWidth() 
{ 
return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null; 
} 
function pageHeight() 
{ 
return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;} 
+0

謝謝,帕特里克! – Zesty 2010-09-16 10:04:09

0

stage.stageWidth和stage.stageHeight