flash on 2013-7-21
別のテキストフィールドへキャレット移動するテスト
♥0 |
Line 29 |
Modified 2013-07-21 22:33:31 |
MIT License
archived:2017-03-30 02:46:12
ActionScript3 source code
/**
* Copyright tepe ( http://wonderfl.net/user/tepe )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/1mOY
*/
package {
//別のテキストフィールドへキャレット移動するテスト
import flash.display.Sprite;
import flash.text.*;
import flash.events.*;
public class FlashTest extends Sprite {
private var tf1:TextField = new TextField();
private var tf2:TextField = new TextField();
public function FlashTest() {
// write as3 code here..
//キャレットの移動テスト
//テキストフィールドに
//[]移動後のキャレット位置を補正したい
tf1.type = "input";
tf2.type = "input";
addChild(tf1);
addChild(tf2);
tf1.text = "tf1";
tf2.text = "tf2";
tf2.x = 200;
stage.focus = tf1;
stage.addEventListener(KeyboardEvent.KEY_DOWN,onKey);
}
private function onKey(e:KeyboardEvent):void{
if(e.keyCode == 39){
if(stage.focus==tf1 && tf1.caretIndex==tf1.length){
e.stopPropagation();
stage.focus= tf2;
tf2.setSelection(0,0);
}
//if(stage.focus == tf1)stage.focus =
//else stage.focus = tf1;
}
}
}
}