
Код AS3:
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
/**
* ...
* @author Aquah
*/
public class Main extends Sprite {
public function Main():void {
if (stage) init();
else super.addEventListener(Event.ADDED_TO_STAGE, this.init);
}
private var _helloTf:TextField;
private var _button:Sprite;
private function init(event:Event = null):void {
super.removeEventListener(Event.ADDED_TO_STAGE, this.init);
this.createTextField();
this.createButton('AddValue');
this._button.addEventListener(MouseEvent.CLICK, this.handler_buttonClick);
super.graphics.lineStyle(5, 0x0000FF);
super.graphics.moveTo(tf.x + tf.width, 0);
super.graphics.lineTo(tf.x + tf.width, 200);
}
private function createTextField():void {
var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.text = 'hello world!!';
super.addChild(tf);
this._helloTf = tf;
}
private function createButton(label:String):void {
var button:Sprite = new Sprite();
button.graphics.lineStyle(0, 0xFF0000);
button.graphics.beginFill(0xFF80FF);
button.graphics.drawRect(0, 0, 100, 25);
button.graphics.endFill();
button.x = 100;
var labelTf:TextField = new TextField();
labelTf.autoSize = TextFieldAutoSize.LEFT;
labelTf.selectable = false;
labelTf.text = label;
labelTf.x = (button.width - labelTf.width) / 2;
labelTf.y = (button.height - labelTf.height) / 2;
button.addChild(labelTf);
super.addChild(button);
this._button = button;
}
private function handler_buttonClick(event:MouseEvent):void {
this._helloTf.y += 10;
}
}
}
вот примерно наш кодстаил с работы, тут текст, линия, кнопочка простейшая, по кнопке текст едет.
Проект в FD приложен.