Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 缺少类EventResize_Actionscript 3_Apache Flex_Air_Flex4 - Fatal编程技术网

Actionscript 3 缺少类EventResize

Actionscript 3 缺少类EventResize,actionscript-3,apache-flex,air,flex4,Actionscript 3,Apache Flex,Air,Flex4,我使用的是AS3 Flex 4.6.0/Air 3.1,找不到ResizeEvent 我添加了以下代码: stage.addEventListener(Event.RESIZE, onStageResize); 并且想要有这个功能 private function onStageResize(ev:Event) : void //Here i want to use ev:ResizeEvent instead of ev:Event { } 我需要ev.OldWidth和ev.OldHe

我使用的是AS3 Flex 4.6.0/Air 3.1,找不到ResizeEvent

我添加了以下代码:

stage.addEventListener(Event.RESIZE, onStageResize);
并且想要有这个功能

private function onStageResize(ev:Event) : void //Here i want to use ev:ResizeEvent instead of ev:Event
{

}
我需要ev.OldWidth和ev.OldHeight属性,我不知道为什么不能使用

 import flash.event.ResizeEvent;
有人有主意吗? 谢谢

Event.RESIZE的导入为:

请记住,仅当设置了StageScaleMode.NO_SCALE时才会触发该事件


导入mx.events.ResizeEvent,尽管我不认为stage会分派它-仅限flex组件。感谢您提供的信息和代码!我会像上面所示那样做,
import flash.events.Event
package {

    import flash.display.Sprite;
    import flash.display.StageScaleMode;
    import flash.events.Event

    public class Main extends Sprite {

        var swfWidthPrev:int;
        var swfHeightPrev:int;

        function resizeDisplay(event:Event):void
        {
            trace("~~~ resize event ~~~");
            trace("swfWidthPrev: " + swfWidthPrev);
            trace("swfHeightPrev: " + swfHeightPrev);
            trace("swfWidthCur: " + stage.stageWidth);
            trace("swfHeightCur: " + stage.stageHeight);
            swfWidthPrev = stage.stageWidth;
            swfHeightPrev = stage.stageHeight;
        }

        public function Main() {
            if(stage){
                stageReady();
            }else{
                this.addEventListener(Event.ADDED_TO_STAGE, stageReady);
            }
        }

        private function stageReady(e:Event = null):void {
            swfWidthPrev = stage.stageHeight;
            swfHeightPrev = stage.stageWidth;
            stage.scaleMode = StageScaleMode.NO_SCALE
            stage.addEventListener(Event.RESIZE, resizeDisplay);
        }
    }
}