flash - Event action on clicking a hyperlink from a textbox -
restating question simpler....
i want able link action script event clicking text within text box.the thing can see create basic hyper link, not apply action:
i have been messing around on hour can't see way apply actionscript , tutorials on internet seem target actionscript 3 or not want.
the reason there background music site , when youtube launched, needs muted. know code mute , have done on custom objects before, can't see way apply script textbox hyperlink.
whilst ideally way, happy consider solution resulting in opening page , muting site.
to honest, tried doing quick switch as3, there many problems need addressing, rather spend time converting site html/jquery or silverlight.... hope there small have overlooked can done without many changes needed.
you can textevent.link event listen user clicks on link in textfield:
import flash.text.textfield; import flash.events.textevent; var textfield:textfield = new textfield(); textfield.htmltext = "<a href='event:arg1,arg2'><b>hyperlink</b></a>"; addchild(textfield); textfield.addeventlistener(textevent.link, ontextfieldlink); function ontextfieldlink(e:textevent):void { var args:array = e.text.split(","); trace(args); // output: arg1, arg2 }// end function
any parts come after "event:" stored in event object's text property. can simulate parsing arguments event object using string.split() method split text string delimiter comma. can store each indvidual element in array.
[update]
for particular scenario(as far understand it), following may better suited you:
import flash.text.textfield; import flash.events.textevent; import flash.net.navigatetourl; import flash.net.urlrequest; var textfield:textfield = new textfield(); textfield.htmltext = "<a href='event:watch?v=jzwedwbj_ic'><b>hyperlink</b></a>"; addchild(textfield); textfield.addeventlistener(textevent.link, ontextfieldlink); function ontextfieldlink(e:textevent):void { var url:string = "http://www.youtube.com/" + e.text; var urlrequest:urlrequest = new urlrequest(url); navigatetourl(urlrequest, "_blank"); }// end function
Comments
Post a Comment