背景付きのリッチテキストがあり、これをマウスの動きで動かしたい
だから私は以下のコードを書きます:(richTextはグローバルフィールドです)
public function createRichText(textPoint:Point):RichText {
richText = new RichText();
var measure:String = correlationMeasure.toFixed(4).toString();
richText.text = measure;
richText.x = textPoint.x;
richText.y = textPoint.y;
richText.width = 60;
richText.height = 24;
richText.setStyle("fontSize", 11);
richText.setStyle("horizontalCenter", "0");
richText.setStyle("verticalCenter", "1");
richText.setStyle("left", "2");
richText.setStyle("right", "2");
richText.setStyle("top", "5");
richText.setStyle("bottom", "5");
richText.setStyle("textAlign", "center");
richText.setStyle("verticalAlign", "middle");
richText.setStyle("backgroundColor", 0xe6e91f);
richText.setStyle("backgroundAlpha", 1);
richText.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, false, 10);
richText.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, false, 10);
return richText
}
private function mouseDownHandler(e:MouseEvent):void {
e.stopPropagation();
allowDraging = true;
richText.addEventListener(MouseEvent.MOUSE_MOVE, dragWithMouse);
}
private function dragWithMouse(e:MouseEvent):void {
if (allowDraging) {
e.stopPropagation();
var temp:Point = richText.contentToGlobal(new Point(e.localX, e.localY));
mousePoint = rootComponent.globalToLocal(temp);
removeChild(richText);
addChild(createRichText(mousePoint));
e.updateAfterEvent();*/
}
}
しかし、それは正しく動作しません...つまり、マウスの動きに合わせて連続的に移動せず、ジャンプします!!! 誰かが理由を知っていますか?