问题
How to handle parent container resize Event or at least browser resize Event ?
I try this code, but handleResize is never call :
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)
}
}
}
Thanks for any help
回答1:
Here's an example of listening to window resize:
<?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>
来源:https://stackoverflow.com/questions/58525420/issue-on-resize-event-with-apache-royale-sdk-0-9-6