Calling ActionScript from Hyperlinks : text event « TextField « Flash / Flex / ActionScript






Calling ActionScript from Hyperlinks

 


package {

  import flash.display.Sprite;
  import flash.text.TextField;
  import flash.events.*;
  
  public class Main extends Sprite {
    public function Main(  ) {
      var field:TextField = new TextField(  );
      field.htmlText = "<a href='event:http://www.java2s.com'>Website</a>";
      field.addEventListener(TextEvent.LINK, onClick);

      addChild(field);
    }
    private function onClick(event:TextEvent):void {
      trace("click");
    }    
  }
}

        








Related examples in the same category

1.Responding to User Text Entry: field.addEventListener(TextEvent.TEXT_INPUT, onTextInput);
2.Prevent Default Test
3.Listening to TextField Events