As 3 drawing board examples and component usages

Source: Internet
Author: User
Tags addchild

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);
}
}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.