|
||||||||||||||
. . . . . |
Creating A Component in Flash 8Create a new Fla. Open the StandardComponent.fla from the C:/Program FilesMacromedia/Flash 8/enConfiguration/ComponentFLA folder. Drag the UIComponent from the StandardComponent.fla library to your new fla library. Its in the Base Classes/FUIComponent Subclasses folder. Create new empty MovieClip. name it widget. Give it the linkage identifier of widget. In the Class box , name the class, Widget. Make sure it is exported for Actionscript and do not tick export in first frame. Open the Component Definitio window and specify the Class name, Widget. In the widget movieclip, create a new frame , call it actions and put the code
Flash Tutorials in Video Format -
Watch them now at LearnFlash.com stop();
on it. Now we create our Widget class. Go, New - ActionScript File. The AS text editor will open. Start creating your class. init method is used to initialize the component. The bounding box is made invisible and size set to 0. If you are extending the MovieClip class, and not the UIComponent superclass, then you may need to initialize an EventDispatcher instance.
createChildren() method attaches and creates objects.
import mx.core.UIComponent;
class Widget extends UIComponent{
// static variables required for createClassObject()
static var symbolName:String = "Widget";
static var symbolOwner:String = "Widget";
// declare a bounding Box
private var boundingBox_mx:MovieClip;
// declare a class variable
private var myLabel:String;
// Constructor
function Widget(){}
// overwrite the superclass UIComponent init method
private function init():Void{
// call superclass init method
super.init();
// hide bounding box and make it size 0
boundingBox_mc._visible = false;
boundingBox_mc._width = 0;
boundingBox_mc._height = 0;
}
// used to attach movieclips, overwrites super method, only used once.
private function createChildren():Void{
}
// called every time component is invalidated
private function draw():Void{
// change layout, sizes etc
}
// to resize our component, invalidates and calls draw method
private function size():Void{
invalidate();
}
// getters and setters.
// Inspectable metatag allows properties to be accessed via the components Property Inspector
[Inspectable]
function set label(text:String):Void{
myLabel = text;
}
function get label():String{
return myLabel;
}
}
That is only the very basic outline of a standard class for a component. Add to it for your own component. Flash 8 Resources
Hollywood 2D Digital Animation: The New Flash Production Revolution |
|
||||||||||||
|
. | Home | Flash MX | Actionscript 2.0 | Flash 3D | Flash 8 | Flash Database | Flash Mobile | Flash CS3 | Java For Kids | Video Course | General Video | Photoshop | Web Design | Digital Photography | Games | free backgrounds | Resume | Streaming Video | Students Work | Links | Contact me | sitemap | reviews | . . |
||||||||||||||