Search This Blog

Sunday, April 15, 2007

Best practices when designing a component

Use the following practices when you design a component:

* Keep the file size as small as possible.

* Make your component as reusable as possible by generalizing functionality.

* Use the Border class rather than graphical elements to draw borders around objects.

* Use tag-based skinning.

* Assume an initial state. Because style properties are on the object, you can set initial settings for styles and properties so your initialization code does not have to set them when the object is constructed, unless the user overrides the default state.

* When defining the symbol, do not select the Export in First Frame option unless it is absolutely necessary. Flash loads the component just before it is used in your Flash application, so if you select this option, Flash preloads the component in the first frame of its parent. The reason you typically do not preload the component in the first frame is for considerations on the web: the component loads before your preloader begins, defeating the purpose of the preloader.

* Always implement an init() method and call the super.init() method, but otherwise keep the component as lightweight as possible.

* Use the invalidate() and invalidateStyle() methods to invoke the draw() method instead of calling the draw() method explicitly.

For More

No comments: