0

如何处理父容器调整大小事件或至少浏览器调整大小事件?

我尝试这段代码,但 handleResize 永远不会调用:

package 
{
    //import org.apache.royale.html.Group;
    import org.apache.royale.jewel.Group;
    import org.apache.royale.core.BrowserResizeListener;

    public class Slideshow extends Group
    {
            public function Slideshow(){
                super();

                this.addBead(new BrowserResizeListener());
                this.addEventListener("sizeChanged",handleResize);
            }

            protected function handleResize():void{
                // this is never called
                trace(this.height)
                trace(this.width)
            }
    }
}

谢谢你的帮助

4

1 回答 1

1

下面是一个监听窗口调整大小的例子:

<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                applicationComplete="applicationCompleteHandler()"
                xmlns:js="library://ns.apache.org/royale/basic"
                >
                <fx:Script>
                    <![CDATA[
                        import org.apache.royale.html.SimpleAlert;

                        private function applicationCompleteHandler():void
                        {
                            myInitialView.addEventListener("sizeChanged", sizeChangedHandler)
                        }

                        private function sizeChangedHandler(event:Event):void
                        {
                            SimpleAlert.show("Application size is: " + this.width + " " + this.height, this);
                        }
                    ]]>
                </fx:Script>
    <js:beads>
        <js:BrowserResizeHandler/>
    </js:beads>

    <js:valuesImpl>
        <js:SimpleCSSValuesImpl />
    </js:valuesImpl>    

    <js:initialView>
        <js:View id="myInitialView" width="100%" height="100%">
            <js:Label text="Hello World"/>  
        </js:View>
    </js:initialView>
</js:Application>
于 2019-10-28T07:09:44.047 回答