views:

12

answers:

1

Hello all,

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 causing 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?

A: 

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.

Jason W
Jason, thank you for the suggestion!I tried what you recommended, but it didn't seem to work. It occured to me that it might be beacuase the actual resizing of the event occurs from an external javascript function. I have updated the original post with more specifics. Any further suggestions would be appreciated