As 3 drawing board examples and component usages
Package
{
Import Flash.display.sprite;
Import flash.events.mouseevent;
public class Classgraphics extends Sprite
{
private Var Mysprite:sprite;
Constructors
Public Function Classgraphics ()
{
This.mysprite = new Sprite ();
Addchild (This.mysprite);
This.mysprite.graphics.beginfill (0x336699);
This.mysprite.graphics.drawrect (0, 0, 550, 400);
This.mysprite.graphics.endfill ();
This.mysprite.addeventlistener (Mouseevent.mouse_down, Spritemousedown);
This.mysprite.addeventlistener (mouseevent.mouse_up, spritemouseup);
}
Mouse Down Event
Private Function Spritemousedown (event:mouseevent): void
{
This.mysprite.graphics.linestyle (1, 0, 1);
This.mysprite.graphics.moveto (MouseX, Mousey);
This.mysprite.addeventlistener (Mouseevent.mouse_move, Spritemousemove);
}
Mouse Left Event
Private Function Spritemouseup (event:mouseevent): void
{
This.mysprite.removeeventlistener (Mouseevent.mouse_move, Spritemousemove);
}
Move events
Private Function Spritemousemove (event:mouseevent): void
{
This.mysprite.graphics.lineto (MouseX, Mousey);
}
}
}
Component uses
Package com
{
Import Flash.display.sprite;
Import flash.events.mouseevent;
Import Flash.display.stagescalemode;
Import flash.display.stagealign;
Import Fl.controls.label;
Import Fl.controls.textinput;
Import Fl.controls.textarea;
Import Fl.controls.button;
public class Classmain extends Sprite
{
private Var username:textinput;
private Var Usernamelabel:label;
private Var Message:textarea;
private Var Messagelabel:label;
private Var Button:button;
Constructors
Public Function Classmain ()
{
Stage.scalemode = "Noscale";
Stage.align = Stagealign.top_left;
THIS.INITMC ();
}
A little prep work.
Private Function INITMC (): void
{
This.username = new TextInput ();
Addinput (This.username, "username", 50, 10, 200, 18);
This.usernamelabel = new label ();
AddLabel (This.usernamelabel, "What is said:", 10, 10, 40, 18);
This.message = new textarea ();
Addtextarea (this.message, "message", 50, 40, 400, 100);
This.messagelabel = new label ();
AddLabel (This.messagelabel, "message:", 10, 40, 40, 18);
This.button = New button ();
AddButton (This.button, "submit", 350, 150);
}
Create label
Private Function AddLabel (Label:label, text:string, X:uint, Y:uint, Width:uint, height:uint): void
{
Label.text = text;
Label.move (x, y);
Label.setsize (width, height);
Addchild (label);
}
Create a text box
Private Function Addinput (Input:textinput, name:string, X:uint, Y:uint, Width:uint, height:uint): void
{
Input.name = name;
Input.move (x, y);
Input.setsize (width, height);
Addchild (input);
}
Create a text field
Private Function Addtextarea (Textarea:textarea, name:string, X:uint, Y:uint, Width:uint, height:uint): void
{
Textarea.name = name;
Textarea.move (x, y);
Textarea.setsize (width, height);
Textarea.condensewhite = true;
Addchild (textarea);
}
Create a button
Private Function AddButton (Button:button, value:string, X:uint, y:uint): void
{
Button.label= value;
Button.move (x, y);
Addchild (button);
}
}
}