To start with, I must say, it was really a good as well as tough time for me, creating my first CS3, component.Good is the way it let me study a lot of blogs, Adobe live docs, Adobe Devenet and a lot of trial and error.It was fun.Tough came in the way when almost all references say a little and when stuck in a problem, I have to re-search and find out. There was no direct reference available to it.But I read the links and articles (mentioned at the end of this topic) at least 10 times each.
Well, lets come directly to the point. One can create Flash CS3 component in several ways. What I mean here is from the root only Flash CS3 supports 2 kinds of components.
1. Pre-compiled Components (SWC components)
2. FLA-based components
When creating SWC components, one have a choice of either following the Flash CS3 component framework or can make a component from ground up without the component framework. I would say taking the help of component framework is better as it does a lot of things automatically. We will discuss both. The same holds good for FLA based components, but here if one does not take component framework’s help, it would take a high amount of time,code, frustration and patience to achieve the same. So again there are 2 choices to component creation
1. with Framework
2. without Framework
Ok, so we now have options to create components. Lets start with creating a component. We will make both, compiled clip, I mean a pre-compiled component, as well as a FLA-based component.But first of all we must know, for creating a component we must use a display object for it. Again we have a choice here, whether to use Movieclip or Sprite. I would say what Jeff Kamerer from Adobe has already stated it in his article,
All of the Flash CS3 components, as well as the Adobe Flex 2 components,inherit from Sprite and not from MovieClip. The class fl.core.UIComponent extends Sprite, so any component built upon the User Interface Component Infrastructure will inherit from Sprite but not from MovieClip.
Inheriting from Sprite instead of MovieClip is a matter of clean design and best practice; when a movie clip will not function as a multi-frame animation, the Timeline-related APIs are an unnecessary distraction, and the restriction against frame scripts enforces the best practice of keeping all code in external ActionScript files.
A component using component framework must inherit from UIComponent as
public class SamScrollBar extends UIComponent
On the other hand a component not using component framework will start as
public class SamScrollBar extends Sprite
With these basic informations, I will close this post.Next we will directly jump into the code of component creation.