as 3 绘图板示例与组件使用实例
package
{
import flash.display.sprite;
import flash.events.mouseevent;
public class classgraphics extends sprite
{
private var mysprite:sprite;
// 构造函数
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);
}
// 鼠标按下事件
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);
}
// 鼠标离开事件
private function spritemouseup(event:mouseevent):void
{
this.mysprite.removeeventlistener(mouseevent.mouse_move, spritemousemove);
}
// 移动事件
private function spritemousemove(event:mouseevent):void
{
this.mysprite.graphics.lineto(mousex, mousey);
}
}
}
组件使用
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);
}
}
}
我的博物馆故事 官方安卓版v1.61.2
我的博物馆故事是一款以消除为主题的经营养成类手游,在这里玩家
专业模拟飞行10 手机版v12.2.4
专业模拟飞行10安卓版是一款飞行休闲手游,顶尖的物理飞行引擎
动物起义战斗模拟器二琳同款 最新版v4.1.1
动物起义战斗模拟器是一个非常有趣的模拟类游戏,玩家可以召唤各
迷你世界七周年 安卓手机版v1.43.0
迷你世界7周年是一款由《迷你世界》官方推出的庆祝特别版本,在
劫后公司无限资源版 v1.0.5.1
劫后公司内置菜单版是游戏的破解版本,在该版本中为玩家提供了内