1 Reply Latest reply on May 10, 2008 8:47 PM by Red_Squirrel

    Actionscript function when hovering

    ArtKohn
      Has anyone ever tried to run an actionscript function when hovering over the <a>Anchor tag of HTMLtext?
      Here is the situation. I have an HTML text field and I want to be able to embed definitions of key words. In turn, when the user hovers over the world, I’d like to open a window containing the definition.
      While one can add a "Hover" effect with CSS, i wish to run a function when an EVENT LINK is hovered over. Can anyone suggest a way to do this or maybe a workaround?

      var htmlText1:String = "<a href='event:hoverOverMe'>Hover Here Please</a>";

      this.textArea1.htmlText = htmlText1;
      this.textArea1.addEventListener("MOUSE_OVER", overHandler)

      public function overHandler(event:MouseEvent)
      {
      //Get mouseover information
      //Possible get information from the anchor tag under the mouse?
      }

      Any help to point me in the right direction is appreciated.
      Art
        • 1. Re: Actionscript function when hovering
          Red_Squirrel
          Hi! This interests me as well, so I'll be following this thread with keen interest. Although the following doesn't answer the question, it does seem to eliminate the possibility of using an anchor tag in the way that you have suggested, the Alert Box in the anonymous function reveals the text and its formatting but the anchor tag has been stripped out.

          But I'm hoping as I guess would you, that the document object model caters for the immediate objects (such as your illustrative tag had it not been stripped out) in the event bubbling phase ... as the Alert box reveals a rich set of tags I should think that there is at least a little hope here.

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application
          xmlns:mx=" http://www.adobe.com/2006/mxml"
          layout="absolute" creationComplete="init()"
          >
          <mx:Script>
          <![CDATA[
          import mx.controls.Alert;
          public function init():void
          {
          testHTML.htmlText="<a id='anchorID' href='#'>This is some text</a>"
          testHTML.addEventListener(MouseEvent.MOUSE_MOVE,function(e:MouseEvent){Alert.show(e.targe t.htmlText.toString());});
          }

          ]]>
          </mx:Script>
          <mx:TextArea id="testHTML" width="300" height="300">

          </mx:TextArea>
          </mx:Application>