开发者

ResizeEvent Looping?

开发者 https://www.devze.com 2022-12-25 12:20 出处:网络
I am having an issue with an actionscript event that I am firing every time a flex component resizes. In the event, I am altering the height of the flash object within its html wrapper via an external

I am having an issue with an actionscript event that I am firing every time a flex component resizes. In the event, I am altering the height of the flash object within its html wrapper via an external javascript function. This in turn causes the component to resize and the event to loop in upon itself and continually add height to the component.

Here is an example of the code cau开发者_开发知识库sing the issue:

private function onCreationComplete(event:Event):void 
{ 
  this.mainInnerShell.addEventListener(Event.RESIZE,handleResize);
} 

private function handleResize(event:Event):void {
  this.mainInnerShell.removeEventListener(Event.RESIZE,handleResize);
  ExternalInterface.call("changePageHeight",this.mainInnerShell.height + resizeBuffer); 
  this.mainInnerShell.addEventListener(Event.RESIZE,handleResize);
}

However, the event fires more than once despite my removal of the event listener. Any suggestions?


Inside the resize event handler you can use removeEventListener to stop listening to that event, make you height changes and then use addEventListener to start listening for resizes again.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号