asfunction协议示例

用于 HTML 文本字段中 URL 的特殊协议,该协议允许 HREF 链接调用 ActionScript 函数.asfunction协议是特定于Flash的一个附加协议,它可使链接调用ActionScript函数.

效果图

ActionScript代码

这个非常简单,这里只贴一下代码:

AS Code
stop ();
var testAStr:String = "<a href='asfunction:showPlayer,a'>Hi,我是A,点我!</a>" + newline + "<a href='asfunction:showPlayer,b'>Hi,我是B,点我</a>";
function showPlayer (person:String)
{
	result_txt.text = "你点击的是" + person;
}
function init ()
{
	html_txt.html = true;
	html_txt.htmlText = testAStr;
	result_txt.text = "结果将显示在这里";
}
init ();

源文件下载

  1. FLA文件:asfunction.fla
  2. SWF文件:asfunction.swf