1
votes

In my Flex application, the modules can be larger than the resolution of the screen and have a vertical scrollbar.

When the user clicks somewhere, I popup a small component at the position of the mouse co-ordinates.

However, if the user clicks too close to the edges of the screen, I need to prevent the component from appearing outside the viewable area.

For this purpose, I need to know the dimensions of the viewable area. I've tried Capabilities.screenResolutionX and Capabilities.screenResolutionY, but they this area will include the browser toolbars.

This.width and this.height obviously won't work as the module will grow beyond 100% height.

So is there any way to compute the available space in the browser (either in actionscript or in javascript)?

2

2 Answers

1
votes

I use the following in Javascript and ExternalInterface to retrieve the results in 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
votes

stage.stageWidth and stage.stageHeight