1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
| 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;
// 构造函数
public function ClassMain()
{
stage.scaleMode = "noScale";
stage.align = StageAlign.TOP_LEFT;
this.initMc();
}
// 一点准备工作
private function initMc():void
{
this.userName = new TextInput();
addInput(this.userName, "userName", 50, 10, 200, 18);
this.userNameLabel = new Label();
addLabel(this.userNameLabel, "呢称:", 10, 10, 40, 18);
this.message = new TextArea();
addTextArea(this.message, "message", 50, 40, 400, 100);
this.messageLabel = new Label();
addLabel(this.messageLabel, "留言:", 10, 40, 40, 18);
this.button = new Button();
addButton(this.button, "提交", 350, 150);
}
// 创建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);
}
// 创建文本框
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);
}
// 创建文本域
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);
}
// 创建按钮
private function addButton(button:Button, value:String, x:uint, y:uint):void
{
button.label= value;
button.move(x, y);
addChild(button);
}
}
} |