开发者

MovieClip.onResize event? how?

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 movieCl开发者_JS百科ip.onResize event?


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.


shouldn't you override set scaleX, scaleY also?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜