TextFlow内部的链接:rollOver / rollOut冒泡,不应冒泡,并且无法避免。

| 我的行为很奇怪。我在TextFlow中有一个HTML链接。当我将其设置为“ 0”时,它将开始沿该链发送rollOver / rollOut事件。这些事件说不要冒泡,但它们会以某种方式发生。而且我似乎无法阻止他们这样做。 这是一个例子:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<s:WindowedApplication xmlns:fx=\"http://ns.adobe.com/mxml/2009\" 
                       xmlns:s=\"library://ns.adobe.com/flex/spark\" 
                       xmlns:mx=\"library://ns.adobe.com/flex/mx\">

  <fx:Declarations>
    <s:TextLayoutFormat id=\"linkNormal\" textDecoration=\"none\" color=\"0x556677\"/>  
    <s:TextLayoutFormat id=\"linkHover\" textDecoration=\"underline\" color=\"0x0000FF\"/>
    <s:TextFlow id=\"textFlow1\" 
                linkActiveFormat=\"{linkHover}\" 
                linkHoverFormat=\"{linkHover}\"
                linkNormalFormat=\"{linkNormal}\">
      <s:p> <s:a href=\"http://projects.nunogodinho.com\">hover</s:a> </s:p>
    </s:TextFlow>
  </fx:Declarations>

  <fx:Script>
    <![CDATA[

      // This pair of handlers is triggered by the panel
      protected function rollOverHandler(e:MouseEvent):void {
        panel.title = \"over\";
      }
      protected function rollOutHandler(e:MouseEvent):void {
        panel.title = \"out\";
      }

    ]]>
  </fx:Script>

  <s:Panel left=\"10\" top=\"10\" id=\"panel\" mouseOver=\"rollOverHandler(event)\" mouseOut=\"rollOutHandler(event)\">
    <s:RichEditableText id=\"ret1\"
                        top=\"10\"
                        editable=\"false\"
                        textFlow=\"{textFlow1}\" />
  </s:Panel>

</s:WindowedApplication>
如果您运行此应用并在链接上多次移动鼠标而不将其移出面板,则会看到它仍会更改文本。 因此,我决定尝试阻止此奇怪事件的冒泡:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<s:WindowedApplication xmlns:fx=\"http://ns.adobe.com/mxml/2009\" 
                       xmlns:s=\"library://ns.adobe.com/flex/spark\" 
                       xmlns:mx=\"library://ns.adobe.com/flex/mx\">

  <fx:Declarations>
    <s:TextLayoutFormat id=\"linkNormal\" textDecoration=\"none\" color=\"0x556677\"/>  
    <s:TextLayoutFormat id=\"linkHover\" textDecoration=\"underline\" color=\"0x0000FF\"/>
    <s:TextFlow id=\"textFlow2\" 
                linkActiveFormat=\"{linkHover}\" 
                linkHoverFormat=\"{linkHover}\"
                linkNormalFormat=\"{linkNormal}\">
      <s:p> <s:a rollOver=\"linkelement2_rollOverHandler(event)\" rollOut=\"linkelement2_rollOutHandler(event)\" href=\"http://projects.nunogodinho.com\">hover</s:a> </s:p>
    </s:TextFlow>
  </fx:Declarations>

  <fx:Script>
    <![CDATA[
      import flashx.textLayout.events.FlowElementMouseEvent;

      // This pair of handlers is triggered by the panel
      protected function rollOverHandler(e:MouseEvent):void {
        panel.title = \"over\";
      }
      protected function rollOutHandler(e:MouseEvent):void {
        panel.title = \"out\";
      }

      // This pair of handlers is triggered by the <A> element inside textFlow2
      // and I hoped it would stop the event from bubbling up to the panel
      protected function linkelement2_rollOverHandler(e:FlowElementMouseEvent):void {
        e.preventDefault();
        e.stopImmediatePropagation();
        e.stopPropagation()
      }
      protected function linkelement2_rollOutHandler(e:FlowElementMouseEvent):void {
        e.preventDefault();
        e.stopImmediatePropagation();
        e.stopPropagation()
      }

      // I also tried to intercept the event in the RichEditableText but got the same weird
      // behavior: the event triggers the panel\'s rollOver/rollOut intermittently


    ]]>
  </fx:Script>

  <s:Panel left=\"10\" top=\"10\" id=\"panel\" mouseOver=\"rollOverHandler(event)\" mouseOut=\"rollOutHandler(event)\">
    <s:RichEditableText top=\"10\" left=\"55\"
                        editable=\"false\"
                        textFlow=\"{textFlow2}\" />
  </s:Panel>

</s:WindowedApplication>
我尝试了
preventDefault
stopImmediatePropagation
stopPropagation
的所有组合。它的确改变了事件的行为,但同时也破坏了链接上的悬停效果。 然后我试图在ѭ6拦截该事件,但得到了相同的结果。 有一次类似的问题,但我知道这是因为我使用的是mouseOver / mouseOut事件,而不是rollOver / rollOut。由于我切换到rollOver / rollOut,所以效果很好。到现在。 现在我一无所有。 请帮忙。 谢谢。     
已邀请:

要回复问题请先登录注册