0

移除 embedFonts 后,它可以按预期完美运行。否则,当单击图像时,它会选择它周围的整个文本。

或者,任何人都可以建议一种方法来设置动态文本字段的样式而不是使用 html?

4

1 回答 1

0

我能够在不使用锚标签的情况下带来相同的效果。显然,将 Anchor 标签与图像一起使用存在错误。无论如何,这就是我为克服这一点所做的。

import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.ui.Mouse;
private function init():void {

     //....
     var txt:String = "Curabitur dolor eros, gravida et.<p class='defStyle'><img src='003.jpg' id='0002'><br><br><br><br><br>Quisque facilisis erat a dui. Nam malesuada ornare dolor. Cras gravida, diam sit amet rhoncus ornare, erat elit consectetuer erat, id egestas pede nibh eget odio.</p>";
     testtext.htmlText=txt;

     var myPattern:RegExp =/<img[^>]+ids*=s*['"]([A-Za-z0-9]+)['"][^>]*\s*>/igmxs;  
     var result:Object = myPattern.exec(txt);

     while (result != null) {
          var id = result[1];
          trace(id);
          var image:DisplayObject = testtext.getImageReference(id);
          image.addEventListener(MouseEvent.CLICK, imgClick);
          image.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
          image.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
          result = myPattern.exec(txt);
      }

     ...//more

}

function imgClick(e:MouseEvent):void {
     trace('hello '+e.target.name);
}
function mouseOverHandler(e:MouseEvent):void {
     Mouse.cursor='button';
}
function mouseOutHandler(e:MouseEvent):void {
     Mouse.cursor='auto';
}
于 2010-05-22T08:49:11.083 回答