Flash 8 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript language elements > Global Functions > asfunction protocol | |||
asfunction:function:Function, parameter:String
A special protocol for URLs in HTML text fields that allows an HREF link to call an ActionScript function. In HTML text fields, you can create links using the HTML A tag. The HREF attribute of the A tag contains a URL that uses a standard protocol such as HTTP, HTTPS, or FTP. The asfunction protocol is an additional protocol that is specific to Flash, which causes the link to invoke an ActionScript function.
Availability: ActionScript 1.0; Flash Player 5
function:String - An identifier for a function.
parameter:String - A string that is passed to the function named in the function parameter.
In the following example, the playMP3() function is defined. The TextField object list_txt is created and set so HTML text can be rendered. The text Track 1 and Track 2 are links inside the text field. The playMP3() function is called when the user clicks either link and plays the MP3 that is passed as a parameter of the asfunction call.
var myMP3:Sound = new Sound();
function playMP3(mp3:String) {
myMP3.loadSound(mp3, true);
myMP3.onLoad = function(success) {
if (!success) {
// code to handle errors here
}
};
}
this.createTextField("list_txt", this.getNextHighestDepth(), 0, 0, 200, 100);
list_txt.autoSize = true;
list_txt.html = true;
list_txt.multiline = true;
list_txt.htmlText = "<a href=\"asfunction:playMP3, track1.mp3\">Track 1</a><br>";
list_txt.htmlText += "<a href=\"asfunction:playMP3, track2.mp3\">Track 2</a><br>";
When you click a link, the MP3 sound file streams in Flash Player.
htmlText (TextField.htmlText property)
Version 8
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/8/main/00001719.html
Comments
No screen name said on Oct 14, 2005 at 6:21 AM : howlongis said on Oct 19, 2005 at 6:23 AM : JimmyMUK said on Oct 24, 2005 at 4:53 PM : cosmits said on Nov 15, 2005 at 2:06 AM : alienorbit said on Dec 1, 2005 at 12:47 AM : Marcílio-BSB said on Dec 9, 2005 at 4:21 AM : SimpleScripter said on Jan 1, 2006 at 5:47 PM : artfabrique said on Jul 18, 2006 at 10:24 PM : NPaquin said on Aug 29, 2006 at 7:41 AM : simonwheatley said on Oct 1, 2006 at 5:07 AM : mgalv said on Dec 7, 2006 at 8:26 AM : Crushed Pineapple said on Jan 2, 2007 at 10:05 AM : No screen name said on Jan 3, 2007 at 6:56 PM : No screen name said on Mar 26, 2007 at 8:48 AM : snowpoi said on Apr 21, 2007 at 10:13 AM : shanstafari said on Apr 24, 2007 at 3:55 PM : No screen name said on Apr 25, 2007 at 11:10 AM : No screen name said on Jul 21, 2007 at 1:33 PM :