Flext text link event doesn't fire until you've clicked it twice
I've got a canvas within which I have a list. The renderer for this list calls upon a "Text" field, with the "link" element of this field set to a function. The "htmlText" of the field is set dynamically to a mixture of words and links. Basically the function checks to see which tag within the htmlText has been clicked and performs an event accordingly.
However, you have to click the link twice for anything to happen. Whilst debugging the code I noticed that the function referenced by the "link" elem开发者_StackOverflow中文版ent isn't actually even called until the 2nd click. Any ideas?
<mx:Text
id="textCanvas"
width="100%"
color="0x323232"
selectable="true"
link="{lbl_link(event)}" />
I've changed the code a little bit to make it easier to follow, but the ActionScript is roughly as follows:
private function creationComplete():void {
textCanvas.htmlText = "Hello <a href='event:username'>" + username + "</a>";
}
private function lbl_link(evt:TextEvent):void {
if( evt.text ){
switch( evt.text ) {
case "username": [[DO SOMETHING]]
}
}
}
The problem may be that you're binding the event handler. Not that this matter anymore 2 years later...
精彩评论