Archive for December 7th, 2007

Flash CS3 component creation : The process

December 7, 2007

Hello and welcome to the component creation steps. Here, we will study how to make a simple component and what are the steps required for it.
1. Create a new Flash actionscript3 document and name it “ScrollBar”.
2. Create a new actionscript class file with name “SamScrollBar” ( I have simply appended first 3 characters of my name before ScrollBar, for some unique class name :) ).
Well, ideally one should save all the component classes inside a package like “com.saumya.components”, but for make the example simple and straight, we will keep the class file in the same folder as our FLA document.
3. So, right now in a folder called “myScrollComponent”, we have two files ( “ScrollBar.fla” and “SamScrollBar.as” )
4. As I have mentioned in my previous post, each component class must extend “UIComponent” class and should have some mandatory methods, I will just write the component template file(I mean a file, which will just have the basic code to make a component).So the class code now, should look like below

package {
import fl.core.UIComponent;
public class SamScrollBar extends UIComponent {

public function SamScrollBar(){
trace(’SamScrollBar : SamSCrollBar : ‘);
super();
}
protected override function configUI():void{
trace(’SamScrollBar : configUI : ‘);
super.configUI();
}
protected override function draw():void{
trace(’SamScrollBar : draw : ‘);

//Lastline
super.draw();
}
public override function setSize(w:Number,h:Number):void{
trace(’SamScrollBar : setSize : ‘);
}
//All the other methods and properties are component specific

}
}

(more…)