Best practices when designing a component
Use the following practices when designing a component:
- Keep the file size as small as possible.
- Make your component as reusable as possible by generalizing functionality.
- Use the new event model rather than the
on(
event
)
syntax.
- Use the Border class rather than graphical elements to draw borders around objects.
- Use tag-based skinning.
- Use the
symbolName
property.
- Assume an initial state. Because style properties are now 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 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.