Skip to content

Instantly share code, notes, and snippets.

@cellfusion
Created October 14, 2009 09:33
Show Gist options
  • Save cellfusion/209922 to your computer and use it in GitHub Desktop.
Save cellfusion/209922 to your computer and use it in GitHub Desktop.
AS3 は asfunction がないので、TextEvent.LINK で受け取った文字列で判別する
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