• flickr
  • linkedin
  • twitter
  • rss
HTMLtext linking to actionscript functions

HTMLtext linking to actionscript functions

You can do it with a link event:

html text would be:

<a href='event:moveUp'>UP</a>

listener on the field:

myHTML.addEventListener(TextEvent.LINK, linkHandler);

function linkHandler(event:TextEvent):void
trace(event.text); // traces 'moveUp'

See this page if that’s not enough:

In as2 it was a bit different, see below:

You can use htmlText to call AS functions. Can put CSS rollover styles and things on too for some lazy-ok-looking action.

See the livedocs for more info

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>";
Tech Reference: ,

Larry's a 30-something chap interested in tramping, being a dork and changing the world via less boring training.

Leave a reply