Flash Tips (5) Flash Player 中 FullScreen 状态下各空间布局及大小控制的 解决办法

   首先 stage.scaleMode = StageScaleMode.NO_SCALE; 否则 全屏时比例拉伸会让按钮很难看,设置为不可拉伸,我们自己去设定元件的位置和大小。

   监听 Resize 事件,在这里重设界面。这样不必费心去接受ESC的事件,它必然会经过这里。

   最后,设置HTML,使之可以全屏。

 

HTML :

<embed src="fullScreenSample.swf" flashvars="file=http://jaris.sourceforge.net/Dame Lo Que Quieras.flv&thumb=lasecta.jpg&logo=logo.png&alphalogo=80" allowFullScreen="true" width="500" height="400" name="fullscreen" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

 

Action Script 3.0 Code:

  1. stage.scaleMode = StageScaleMode.NO_SCALE;
  2. stage.align = StageAlign.TOP_LEFT;
  3. stage.addEventListener(Event.RESIZE, positionHandler);
  4. //This button use to switch the screen state between fullscreen and normal.
  5. button.buttonMode = true;
  6. button.gotoAndStop("normalState");
  7. button.addEventListener(MouseEvent.CLICK, fullScreenHandler);
  8. var bFullscreen : Boolean = false;
  9. function fullScreenHandler(event:MouseEvent):void { 
  10.     if (parent.stage.displayState == StageDisplayState.FULL_SCREEN) {
  11.         parent.stage.displayState = StageDisplayState.NORMAL;
  12.         output.appendText("Back to Normal Screen/n");
  13.         button.gotoAndStop("normalState");
  14.     } else {
  15.         parent.stage.displayState = StageDisplayState.FULL_SCREEN;
  16.         output.appendText("In FullScreen/n");
  17.         button.gotoAndStop("fullscreenState");
  18.     }
  19. }
  20. //Use the Resize Event to Catch the ESC key
  21. function positionHandler(event:Event):void {
  22.     setPosition();
  23. }
  24. function setPosition() {
  25.     bFullscreen = !bFullscreen;
  26.     if(bFullscreen)
  27.         button.gotoAndStop("fullscreenState");
  28.     else
  29.         button.gotoAndStop("normalState");
  30.     bar.width = stage.stageWidth;
  31.     bar.x = 0;
  32.     bar.y = stage.stageHeight - bar.height;
  33.     button.x = 0;
  34.     button.y = bar.y - button.height;
  35.     scene.x = 20;
  36.     scene.y = 20;
  37. }

完整的源代码,我已经上传,链接为:

http://download.csdn.net/source/688167

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值