I want to change the view states in my flex app when it resizes in the browser window. I have the swf embedded at 100% x 100%. So when the user resizes the window below a certain width, I want to switch to a different state. I tried adding an event listener like this, but it only fires the event when I resize the swf outside the browser, not inside. I used: this.addEventListener(ResizeEvent.RESIZE, SizeChanged); I want this to work within the browser. I even tried using fixed dimensions in the embed code, instead of percentages, but that didn't help either.
A:
You want to add the listener to the stage.
this.stage.addEventListener( Event.RESIZE, resizeHandler ); //from your Main.mxml creationComplete handler
Or you can add a listener via:
Application.application.stage.addEventListener( Event.RESIZE, resizeHandler)
Also, keep in mind that this event fires a lot as the view is resizing, so you will want to account for that.
Joel Hooks
2009-08-06 01:47:14