AS3
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:
http://blog.circlecube.com/2008/12/portfolio/asfunction-texteventlink-tutorial-for-as3-flash-html-link-to-call-actionscript-function-tutorial/
In as2 it was a bit different, see below:
AS2:
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
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001719.html
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>";
Leave a Reply