これに対する解決策が見つかったかどうかはわかりませんが、より簡単なアプローチがあります。このコードは、キャプチャ フェーズ中 (表示前) に tooltip-show イベントにフックし、含まれる要素 (「この」場合はドキュメント) のスケールに基づいて適切にスケールおよび配置しparentApplication
ます。また、私の場合、スケーリング時にツールチップがステージから外れないようにするのに役立つコードも少し含まれています (そのため、最初の数行だけが必要になる場合がありますt.scaleX
) t.scaleY
。
import mx.events.ToolTipEvent;
addEventListener(ToolTipEvent.TOOL_TIP_SHOW, handleToolTipShow, true, 0, true);
private function handleToolTipShow(event:ToolTipEvent):void
{
if (event && event.toolTip)
{
var t:IToolTip = event.toolTip;
// Scale the tip itself
t.scaleX = this.scaleX;
t.scaleY = this.scaleY;
// Scale the offsets
var xOffset:int = 10 * this.scaleX;
var yOffset:int = 10 * this.scaleY;
// Set the default positioning
t.x = parent.mouseX + xOffset;
t.y = parent.mouseY + yOffset;
// Set the adjusted height and width
var th:Number = t.height * this.scaleX;
var tw:Number = t.width * this.scaleY;
var rightEdge:int = t.x + tw + xOffset;
var playerRightEdge:int = parent.width;
var bottomEdge:int = t.y + th + yOffset;
var playerBottomEdge:int = parent.height;
// Offscreen right
if (rightEdge > playerRightEdge)
{
t.move(parent.mouseX - xOffset - tw, parent.mouseY + yOffset);
}
// Offscreen bottom
if (bottomEdge > playerBottomEdge)
{
t.move(parent.mouseX + xOffset, parent.mouseY - yOffset - th);
}
}
}