views:

138

answers:

2

I have a website which is built totally in flex.

I want to make a button, on the click of which the browser becomes fullscreen. I am not talking about a flex fullscreen, by which i mean "Application.application.stage.displayState = StageDisplayState.FULL_SCREEN;" I dont want to use this.

The reason, I dont want to use it is, that flash does not supports keyboard on flex-fullscreen. But if i can make the browser fullscreen, it will solve my purpose.

Plz help me with this.

Also i am hoping the same method will be good for all browsers on PC and Mac both.

Regards Zeeshan

+3  A: 

Use ExternalInterface to call a javascript function for it. Sorry this solution is half-baked so I'm not 100% sure it works..

//In ActionScript
public function fullScreen():void
{
  if (ExternalInterface.available) 
  {
    ExternalInterface.call("fullScreen");
  } 
  else
  {
    //Error
  }
}
//In JavaScript
function fullScreen()
{
  if (parseInt(navigator.appVersion)>3) {
    moveTo(0,0);
    resizeTo(screen.availWidth,screen.availHeight);
  }
  //on older browsers just leave it alone
}
eSniff
BTW: got the sample code from http://www.javascripter.net/faq/resizing.htm I tested their sample; Works for Firefox and IE, doesn't work for Chrome.
eSniff
thanks for the answer, but I want the screen to go fullscreen. How do I do that?That cannot be static number, as the screen size change per user. I am looking for a functionality that would look like the F11(fullscreen) for browser.
Zeeshan Rang
What are you talking about ? That is full screen. It is not a static number. Have you even tried it ?
phwd
If you type screen.availHeight in a javaScript console it returns the height of your screen. For example on mine it returns 1050 and screen.availWidth returns 1920. These variables are created by the user's browser and are not constant for all users.
eSniff
the answer you have give just resizes the window to cover the entire screen, but does not make the browser full-screen. And that is what m looking for.
Zeeshan Rang
A: 

i did the same work using thw solution for which you r saying no, u r saying the keyboard doesn't work, but it's working in ma case

here is the button code :

<mx:Button id="fullscreen" styleName="fullscreen" click="toggleFullScreen();"/>

and here is the function which gets called :-

private function toggleFullScreen():void
{
    if(Application.application.stage.displayState == StageDisplayState.NORMAL)
    Application.application.stage.displayState = StageDisplayState.FULL_SCREEN;
    else if(Application.application.stage.displayState == StageDisplayState.FULL_SCREEN)
     Application.application.stage.displayState = StageDisplayState.NORMAL;
}

also there are some files , that u need to copy in the html-template folder:-

i'll send u those files, mail me [email protected], i'll reply u

and yes, when u r in full screen mode, u can press "esc" key to get to the normal mode, and if u want to use keyboard to make fullscreen, then u keyboard events, thats a different story

i hope this helps

tc hav a gr8 time

Ankur Sharma
when i say the keyboard does not works, i mean the alphabets. I have a InputTextbox, on full-screen i can not write anything into it. Does that happens for you, i am doubtful about that.
Zeeshan Rang
ok, u r doin much more work in fullscreen mode, no i didn't worked on this, but i beleive u should study the tab loop, which describes about the component prority and learn keyboard events, that could give u some solution,my project was to just enable the fullscreen mode, thats it
Ankur Sharma