Flash CS3 Documentation |
|||
| Using ActionScript 2.0 Components > Creating Components > Creating the ActionScript class file > About core functions > Defining the size() method | |||
When a component is resized at runtime using the componentInstance.setSize() method, the size() function is invoked and passed width and height properties. You can use the size() method in the component's class file to lay out the contents of the component.
At a minimum, the size() method should call the superclass's size() method (super.size()).
In the following example from the Dial component (see Building your first component), the size() method uses the width and height parameters to resize the dial movie clip:
function size():Void {
super.size();
dial._width = width;
dial._height = height;
invalidate();
}
Call the invalidate() method inside the size() method to tag the component for redraw instead of calling the draw() method directly. For more information, see About invalidation.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00002512.html