asfunction

Availability

Flash Player 5.

Usage

asfunction:function,"parameter"

Parameters

function An identifier for a function.

parameter A string that is passed to the function named in the function parameter.

Returns

Nothing.

Description

Protocol; a special protocol for URLs in HTML text fields. In HTML text fields, text may be hyperlinked using the HTML A tag. The HREF attribute of the A tag contains a URL that may be for a standard protocol like HTTP, HTTPS, or FTP. The asfunction protocol is an additional protocol specific to Flash, which causes the link to invoke an ActionScript function.

Example

In this example, the MyFunc() function is defined in the first three lines of code. The TextField object myTextField is associated with an HTML text field. The text "Click Me!" is a hyperlink inside the text field. The MyFunc() function is called when the user clicks on the hyperlink:

function MyFunc(arg){
  trace ("You clicked me! Argument was "+arg);
}
myTextField.htmlText ="<A HREF=\"asfunction:MyFunc,Foo \">Click Me!</A>";

When the hyperlink is clicked, the following results are displayed in the Output panel:

You clicked me!  Parameter was Foo