我有一个全屏按钮,当点击该按钮更改舞台的displayState为 StageDisplayState.FULL_SCREEN_INTERACTIVE
的应用程序。
I have an application with an fullscreen button, when that button is clicked I change the displayState of stage to StageDisplayState.FULL_SCREEN_INTERACTIVE
.
这使得 Event.RESIZE
火两次,如果在Stage.scaleMode = StageScaleMode.NO_SCALE时
。
That makes Event.RESIZE
fire twice if stage.scaleMode = StageScaleMode.NO_SCALE
.
本次活动只fireing一次,如果我变回 stage.displayState = StageDisplayState.NORMAL
。
The event is only fireing once if i change back to stage.displayState = StageDisplayState.NORMAL
.
任何人都知道一个好办法prevent的Event.RESIZE从除直接调用函数的onResize或实现自定义事件fireing两次?
Anyone know a good way to prevent the Event.RESIZE from fireing twice except calling the onResize function directly or implementing a custom event?
样品code重现该问题:
Sample code that reproduces the issue:
package test
{
import flash.display.Sprite;
import flash.display.StageDisplayState;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
public class Main extends Sprite
{
public function Main():void
{
if (stage)
this.init();
else
this.addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
this.removeEventListener(Event.ADDED_TO_STAGE, init);
stage.addEventListener(Event.RESIZE, onResize);
stage.scaleMode = StageScaleMode.NO_SCALE;
var button:Sprite = new Sprite();
button.mouseEnabled = true;
button.addEventListener(MouseEvent.CLICK, doResize);
button.graphics.lineStyle(3,0x00ff00);
button.graphics.beginFill(0x0000FF);
button.graphics.drawRect(10, 10, 100, 100);
button.graphics.endFill();
this.addChild(button);
}
private function doResize(e:MouseEvent) : void {
if (stage.displayState == StageDisplayState.NORMAL) {
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}
else {
stage.displayState = StageDisplayState.NORMAL;
}
}
private function onResize(e:Event) : void {
trace("onResize", stage.displayState);
}
}
}
进一步的调查表明,这似乎是切换到全屏的两个步骤,第一个调整到 StageDisplayState.NORMAL
再到 StageDisplayState.FULL_SCREEN_INTERACTIVE
。
看起来这是仅限于调试播放器中的错误。
It seems like this is a bug limited to the debug player.
Debug版本的Flash Player 11.1重现这个bug,而Chrome 11.2版和浏览器插件11.1没有。
Debug version of Flash Player 11.1 reproduces this bug, while the Chrome version 11.2 and browser plugin 11.1 does not.