你面臨的問題是,圖像不會定期調度事件的顯示列表將其他元素。爲了更加精確,也不會派遣MOUSE_OVER或ROLL_OVER事件,爲您偵聽和顯示工具提示。
所以你必須要偵聽整個RichEditableText將這些事件,並做一些命中測試,以檢測鼠標是否是在圖像或沒有。
假設你有一些文本流是這樣的:
<s:RichEditableText width="100%" height="100%" mouseOver="toggleTooltip()">
<s:textFlow>
<s:TextFlow>
<s:p>
<s:span>Some text before</s:span>
<s:img id="myImg" source="myImg.png" />
<s:span>Some text after</s:span>
</s:p>
</s:TextFlow>
</s:textFlow>
</s:RichEditableText>
你聽對整個TextComponent中鼠標懸停事件。
然後以測試鼠標在你的形象,實現了鼠標懸停處理程序:
private function toggleTooltip():void {
var graphic:DisplayObject = myImg.graphic;
var anchor:Point = graphic.localToGlobal(new Point(0, 0));
if (mouseX >= anchor.x && mouseX <= anchor.x + graphic.width &&
mouseY >= anchor.y && mouseY <= anchor.y + graphic.height)
{
trace('show tooltip');
}
else {
trace('hide tooltip');
}
}
糟糕!按錯鍵!我試圖在解決ID ccIMG 0的初始化函數設置提示嘗試了沒有運氣(不記得現在!) – MCE
哇其他的事情! Flextras有代表在最高的1%!真棒! – MCE