views:

367

answers:

2

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?

A: 

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 x(value:Number):void{
  super.x = value;
  dispatchResizeEvent();
}

override public function set y(value:Number):void{
  super.y = 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
just enough to get the point. Thx
Phil
A: 

shouldnt you create an override for set width/height too?

dom