Created
October 14, 2009 09:33
-
-
Save cellfusion/209922 to your computer and use it in GitHub Desktop.
AS3 は asfunction がないので、TextEvent.LINK で受け取った文字列で判別する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tf:TextField = new TextField(); | |
tf.multiline = true; | |
tf.autoSize = TextFieldAutoSize.LEFT; | |
tf.text = "<a href='event:hoge|args1,args2'>hoge</a> fuga"; | |
tf.addEventListenener(TextEvent.LINK, linkHandler); | |
addChild(tf); | |
function linkHandler(event:TextEvent):void | |
{ | |
trace(event.text); // trace -> hoge|args1,args2 | |
var name:String = event.text.split('|')[0]; | |
var args:Array = event.text.split('|')[1].split(','); | |
switch (name) { | |
case "hoge": hoge.apply(args); | |
} | |
} | |
function hoge(args1:String, args2:String):void | |
{ | |
trace('hoge args1:'+args1+', args2:'+args2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment