Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well there is no standard solution for this. You could create a custom class which overrides the setters of width/height/x/y/scaleX/scaleY/scrollRect .. and maybe some other properties. The children should extend such a class.</p> <p>I used a boolean to prevent its dispatched multiple times, after a frame the flag will be resetted.</p> <pre><code>override public function set width(value:Number):void { if (value !== super.width &amp;&amp; !isNaN(Number(value)) this.dispatchResize(); super.width = value; } override public function set height(value:Number):void { if (value !== super.height &amp;&amp; !isNaN(Number(value)) this.dispatchResize(); super.height = value; } override public function set scaleX(value:Number):void { if (value !== super.scaleX &amp;&amp; !isNaN(Number(value)) this.dispatchResize(); super.scaleX = value; } override public function set scaleY(value:Number):void { if (value !== super.scaleY &amp;&amp; !isNaN(Number(value)) this.dispatchResize(); super.scaleY = value; } private var _hasDispatchedResize:Boolean; protected function dispatchResize():void { // do something if (!this._hasDispatchedResize) { this.dispatchEvent(new Event(Event.RESIZE)); this._hasDispatchedResize = true; this.addEventListener(Event.ENTER_FRAME, handleEnterFrameOnce); } } private function handleEnterFrameOnce(event:Event):void { this.removeEventListener(Event.ENTER_FRAME, handleEnterFrameOnce); this._hasDispatchedResize = false; } </code></pre> <p>Now, in the container class you can listen to a <code>Event.RESIZE</code> of the children. Your not really sure if the value actually changed (in case of a frame change on a MovieClip), but in most cases this will work. I've added an extra check inside this setters before dispatching the resize. It depends on the case if this will suit your case.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload