flash on 2009-12-18
♥0 |
Line 71 |
Modified 2009-12-18 17:02:58 |
MIT License
archived:2017-03-30 10:10:40
ActionScript3 source code
/**
* Copyright 9re ( http://wonderfl.net/user/9re )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/fHyV
*/
package {
import flash.net.LocalConnection;
import flash.text.TextFieldType;
import flash.text.TextField;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
var tf:TextField;
addChild(new LocalConnectionTest);
}
}
}
import flash.net.*;
import flash.text.*;
import flash.display.Sprite;
class Button extends Sprite {
private var _tf:TextField;
public function Button() {
_tf = new TextField;
_tf.defaultTextFormat = new TextFormat('_sans', 12, 0xffffff);
_tf.selectable = false;
_tf.mouseEnabled = false;
addChild(_tf);
buttonMode = true;
tabEnabled = false;
}
public function set label(value:String):void {
_tf.text = value;
update();
}
private function update():void {
_tf.width = _tf.textWidth + 6;
_tf.height = _tf.textHeight + 4;
graphics.clear();
graphics.beginFill(0x333333);
graphics.drawRect(0, 0, _tf.width, _tf.height);
}
}
class LocalConnectionTest extends Sprite {
private static const FIRST_CONNECTION:String = '_first_connection_';
private var _messageArea:TextField;
public function LocalConnectionTest() {
var input:TextField = new TextField;
input.type = TextFieldType.INPUT;
input.defaultTextFormat = new TextFormat('_sans', 12, 0xffffff);
input.width = 120;
input.background = true;
input.backgroundColor = 0x555555;
addChild(input);
var btn:Button = new Button;
btn.label = 'send';
btn.x = input.width;
input.height = btn.height;
addChild(btn);
_messageArea = new TextField;
_messageArea.width = input.width + btn.width;
_messageArea.y = btn.height;
addChild(_messageArea);
var lcSend:LocalConnection = new LocalConnection;
lcSend.connect(FIRST_CONNECTION);
}
public function setMessage(value:String):void {
_messageArea.text = value;
}
}
class Text extends TextField {
override public function set text(value:String):void {
super.text = value;
height = textHeight + 4;
}
}