动作脚本全屏不允许

时间:2013-04-15 19:21:02

标签: actionscript-3 flash

这是我将代码添加到舞台上的代码

private function add_fullScreenBtn(height:Number):void
{

    button_fullScr = new Sprite();
    button_fullScr.useHandCursor = true;
    button_fullScr.buttonMode = true;
    button_fullScr.mouseChildren = false;

    button_fullScr.x = height;
    button_fullScr.y = btn_y;

    var fullScr_Btn:Bitmap = new fullScreenImage();
    button_fullScr.addChild(fullScr_Btn);        
    button_fullScr.addEventListener(MouseEvent.CLICK, fullScreenHandler);
    addChild(button_fullScr);

}

这是用户点击全屏按钮时处理事件的代码

private function fullScreenHandler(event:MouseEvent):void
{
    trace("Here");
   // stage.displayState = StageDisplayState.FULL_SCREEN
    if (this.stage.displayState== StageDisplayState.NORMAL) {
        //stage.displayState="fullScreen";
        this.stage.displayState=StageDisplayState.FULL_SCREEN_INTERACTIVE;
        stage.scaleMode = StageScaleMode.NO_SCALE;
    } else {
        //stage.displayState="normal";
        this.stage.displayState=StageDisplayState.NORMAL;
    }
}

这是html页面的代码

 <html>
      <head>This is the Test Page    
      </head>
      <body>
     <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 
       codebase="http://.../swflash.cab#version=9,0,0,0" 
       width="550" height="400" id="sample" align="middle">      
       <param name="allowScriptAccess" value="sameDomain" />
       <param name="allowFullScreen" value="true" />      
       <param name="movie" value="sample.swf" />
       <param name="quality" value="high" />
       <param name="bgcolor" value="#333333" />
       <embed src="sample.swf" quality="high" bgcolor="#333333" 
           width="550" height="400" 
           name="sample" align="middle" 
           allowscriptaccess="sameDomain" 
           type="application/x-shockwave-flash" 
           allowFullScreen="true" 
           pluginspage="http://www.macromedia.com/go/getflashplayer" />
      </embed>
    </object>

      </body>
    </html>

当我运行此页面时,我收到的错误是不允许使用全屏模式。安全例外。当我在控制台上跟踪它时,打印“在这里”

任何人都可以建议我如何解决错误

1 个答案:

答案 0 :(得分:0)

我必须添加线来缩放图像,即我添加了以下行

stage.scaleMode = StageScaleMode.NO_SCALE;

之前

stage.displayState = StageDisplayState.FULL_SCREEN;

并且有效