hello, all
i have a nice piece of code to set the fullscreen with dynamic text formatting (below)
what i am trying to do is add in a key event listener for the escape key, so that if the user hits esc instead of the button, it will also reset the button’s ‘normal view’ settings
i have tried to do a test in a separate fla but even with just a trace on the function, when i hit esc all the swf does is stop (odd!)
any thoughts would be appreciated; thanks!
//bu for fullscreen clicks
goFull_bu.addEventListener(MouseEvent.MOUSE_OVER, fullOver);
goFull_bu.addEventListener(MouseEvent.MOUSE_OUT, fullOut);
goFull_bu.addEventListener(MouseEvent.CLICK, goFull);
goFull_bu.mouseChildren = false;
goFull_bu.buttonMode = true;
//add a listener to the stage to respond to fullscreen events
this.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenHandler);
function fullOver(event:MouseEvent):void
{
if (stage.displayState == StageDisplayState.NORMAL)
{
this.goFull_bu.gotoAndStop("normalOver");
}
else
{
this.goFull_bu.gotoAndStop("fullscreenOver");
}
}
function fullOut(event:MouseEvent):void
{
if (stage.displayState == StageDisplayState.NORMAL)
{
this.goFull_bu.gotoAndStop("normalView");
}
else
{
this.goFull_bu.gotoAndStop("fullscreenView");
}
}
function goFull(event:MouseEvent):void
{
if (stage.displayState == StageDisplayState.NORMAL)
{
stage.displayState = StageDisplayState.FULL_SCREEN;
this.goFull_bu.gotoAndStop("fullscreenView");
}
else
{
stage.displayState = StageDisplayState.NORMAL;
this.goFull_bu.gotoAndStop("normalView");
}
}
//apply kerning to the dynamic text in the fullscreen bu
var myFormat:TextFormat = new TextFormat();
myFormat.letterSpacing = 2;
//listen for fullscreen event, and change the text
function fullScreenHandler(event:FullScreenEvent):void
{
if(event.fullScreen)
{
trace("full");
this.goFull_bu.btn_txt.defaultTextFormat = myFormat;
this.goFull_bu.btn_txt.text = "EXIT FULLSCREEN";
this.goFull_bu.gotoAndStop("fullscreenView");
}
else
{
trace("normal");
this.goFull_bu.btn_txt.text = "VIEW FULLSCREEN";
this.goFull_bu.gotoAndStop("normalView");
}
}