〜 on Mac
♥0 |
Line 23 |
Modified 2010-05-24 23:44:31 |
MIT License
archived:2017-03-30 10:07:55
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/eiXR
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.TextEvent;
import flash.text.TextFieldType;
public class FlashTest extends Sprite {
public function FlashTest() {
/*
マックの~は「波ダッシュ」という文字だそうな。
http://blog.nautes.cc/?p=337
*/
var tf:TextField = new TextField;
tf.border = true;
tf.x = 5;
tf.y = 5;
tf.width = tf.height = 200;
tf.type = TextFieldType.INPUT;
tf.addEventListener(TextEvent.TEXT_INPUT, onTextInput);
addChild(tf);
function onTextInput(e:TextEvent):void {
// 波ダッシュが表示できないという環境は少なくないと思われるので、
// 全角チルダに置き換える
var str:String = e.text.replace(String.fromCharCode(12316), '~');
e.preventDefault();
tf.replaceSelectedText(str);
}
}
}
}