gpt4 book ai didi

actionscript-3 - 在 flex 中用鼠标移动移动富文本

转载 作者:行者123 更新时间:2023-12-02 02:01:00 26 4
gpt4 key购买 nike

我有一个带背景的 richText,我想用鼠标移动它

所以我写了下面的代码:(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();*/
}
}

但它不能正常工作......意味着它不会随着鼠标移动而连续移动并且有跳跃!有谁知道为什么?

最佳答案

试试 startDrag()stopDrag() Sprite 类中定义的方法:

  private function mouseUpHandler(e:MouseEvent):void {
e.stopPropagation();
richText.stopDrag();
}

private function mouseDownHandler(e:MouseEvent):void {
e.stopPropagation();
richText.startDrag();
}

关于actionscript-3 - 在 flex 中用鼠标移动移动富文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17208276/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com