1

I have a an swf, called 'controls' that I created with flash cs4. I upload the controls.swf to my web server. I create an application in flex and it loads the external swf controls into itself. So far I can manipulate the controls.swf via my flex app.

I created a class in my external swf, but I need to add some onResize event/check to my scroll bar. For example, if my scrollbar size increases/decreases, I want it to change variable values. Is there some movieClip.onResize event?

Phil
  • 261
  • 2
  • 7
  • 20

2 Answers2

4

Unfortunately, there's no onResize event for Movieclips. However, you can make one! In the controls.swf make a document class. We'll call it Controls.as and it should extend MovieClip. In Controls.as have something like this:

override public function set width(value:Number):void{
  super.width = value;
  dispatchResizeEvent();
}

override public function set height(value:Number):void{
  super.height = value;
  dispatchResizeEvent();
}

private function dispatchResizeEvent():void{
  dispatchEvent(new Event("MovieClipResize", true));
}

When you load in the swf add an event listener for MovieClipResize:

controlsSwf.addEventListener("MovieClipResize", onMovieClipResize);

I wrote this off the cuff, so it's editable. It's also simplified a bit and not super optimized but hopefully it can get you going.

Newtang
  • 6,414
  • 10
  • 49
  • 70
0

shouldn't you override set scaleX, scaleY also?

reelfernandes
  • 181
  • 2
  • 5