flash on 2010-11-27
Windowsのファイル名とかのアレっぽいやつ
F2を押すとテキストを編集できる
♥0 |
Line 50 |
Modified 2010-11-28 00:42:50 |
MIT License
archived:2017-03-20 05:35:52
ActionScript3 source code
/**
* Copyright enecre ( http://wonderfl.net/user/enecre )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/t5cd
*/
package {
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.text.*;
import flash.display.Sprite;
import com.bit101.components.*;
[SWF(backgroundColor=0xaaaaff, frameRate=20)]
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var winlabel:WinLabel = new WinLabel();
winlabel.text = "test";
addChild(winlabel);
}
}
}
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.text.*;
import flash.display.*;
[Event(name="change", type="flash.events.Event")]
class WinLabel extends Sprite{
public static const CHANGE:String = "change";
private function get __editing():Boolean{ if(_tf.type == "dynamic")return false; else return true;} //normal or editing
private function set __editing(value:Boolean):void{ if(value)_tf.type = "input"; else _tf.type = "dynamic" }
protected var _tf:TextField;
protected var _textformat:TextFormat;
protected function get _editing():Boolean{ return __editing; }
protected function set _editing(value:Boolean):void{ __editing = value;}
public function get text():String{ return _tf.text; }
public function set text(value:String):void{ _tf.text = value; }
public function get textSize():int{ return int(_textformat.size); }
public function set textSize(value:int):void{ _textformat.size = value; }
public function get fontFamily():String{ return _textformat.font; }
public function set fontFamily(value:String):void{ _textformat.font = value; }
function WinLabel(){
_tf = new TextField();
_editing = false;
_textformat = new TextFormat();
_tf.setTextFormat(_textformat);
addChild(_tf);
addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
}
private function onKeyDown(e:KeyboardEvent):void{
switch(e.keyCode){
case 13: {if(_editing){ _editing = false; dispatchEvent(new Event("change")); } break; }
case 113: {if(!_editing)_editing = true; break;}
default: break;
}
}
}