Actionscript 3 坐标don';t更改拖动缩放的fxg图形

Actionscript 3 坐标don';t更改拖动缩放的fxg图形,actionscript-3,scale,flashdevelop,fxg,Actionscript 3,Scale,Flashdevelop,Fxg,我正在使用FlashDevelop、ActionScript3和fxg图形构建以及Illustrator(作为FXG2.0导出) 我用Illustrator导入了一个fxg矩形构建,然后当你点击它时,我将它设置为可拖动的,所以它的坐标会改变。如果矩形比例为1(这意味着:无比例),则此操作有效。 但是,如果我改变它的比例(例如fxgRect.scaleX=fxgRect.scaleY=0.5;),你可以拖动它,但它的坐标不变!!这让我抓狂,因为精灵改变了位置,但如果你问它的坐标,它们不会改变!!

我正在使用FlashDevelop、ActionScript3和fxg图形构建以及Illustrator(作为FXG2.0导出)

我用Illustrator导入了一个fxg矩形构建,然后当你点击它时,我将它设置为可拖动的,所以它的坐标会改变。如果矩形比例为1(这意味着:无比例),则此操作有效。 但是,如果我改变它的比例(例如fxgRect.scaleX=fxgRect.scaleY=0.5;),你可以拖动它,但它的坐标不变!!这让我抓狂,因为精灵改变了位置,但如果你问它的坐标,它们不会改变!! 我将
fxgRect.mouseChildren=false所以我确定要移动精灵fxgRect,而不是它里面的东西。
(这只是一个例子,我的目标是使用illustrator构建复杂的图形,并在FlashDevelop中使用它)

提前谢谢你对我的帮助

这是用来测试这个问题的代码。要使用此示例,必须创建一个fxg矩形(fxgrectangle.fxg),并将其放在SimpleDragFxg.as类的同一文件夹中

import flash.display.*;
import flash.events.*;
import fxgrectangle;

public class SimpleDragFxg extends Sprite
{
    public var fxgRect:Sprite = new fxgrectangle(); // make an istance of fxgRect

    public function SimpleDragFxg()
    {
        //----------------------------------------------------------
        addChild(fxgRect);
        fxgRect.name = "FXGrect";
        fxgRect.x = fxgRect.y = 50;
        fxgRect.mouseChildren = false;
        fxgRect.scaleX = fxgRect.scaleY = 0.5; //<<< this makes the problem
        trace ("I'm ", this.name, "and I contain ", this.fxgRect.name, "which contains ", fxgRect.getChildAt(0).name);
        fxgRect.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
        //--------------------------------------------------------------
    }
    private function onMouseDown (e:MouseEvent):void
    {
        trace ("e.target: ", e.target.name);
        if (DisplayObject(e.target).name == "FXGrect")
        {
            trace ("FXGrect position BEFORE drag: ", fxgRect.x, fxgRect.y);
            Sprite(e.target).startDrag();
            stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
        }
    }
    private function onMouseUp (e:MouseEvent):void
    {
        fxgRect.stopDrag();
        stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
        if (DisplayObject(e.target).name == "FXGrect")
        {
            trace ("FXGrect position AFTER drag: ", fxgRect.x, fxgRect.y);
        } 
    }
}
导入flash.display.*;
导入flash.events.*;
导入fxgrectangle;
公共类SimpleDragFxg扩展了Sprite
{
public var fxgRect:Sprite=new fxgrectangle();//设置fxgRect的距离
公共函数SimpleDragFxg()
{
//----------------------------------------------------------
addChild(fxgRect);
fxgRect.name=“fxgRect”;
fxgRect.x=fxgRect.y=50;
fxgRect.mouseChildren=false;
fxgRect.scaleX=fxgRect.scaleY=0.5;//


你不能缩放被拖动的项目吗?我的意思是不要对被拖动的项目应用转换,而是要有一个将被拖动的容器和将应用转换的内容。你还可以跟踪更多内容(例如目标);在onMouseDown和onmousedup中?也许你拖动的不是你认为拖动的:):):)是的,也许我可以使用非缩放项目,但当我发现问题时,我会尝试解决它。谢谢你评论我的问题。是的,它很有效!!!太好了!知道它为什么以这种方式工作会很有趣。它似乎与我的非常相似。无论如何,非常感谢你太多了。我会投票支持你的答案,但我的声誉太低了,我不能……:)太好了!知道它为什么会以这种方式工作会很有趣“将问题块封装到movieclip中是一种非常古老的解决方法,我使用它和模拟收据,因为Flash 4:)你需要使用这种技巧来处理没有好的setter和主要问题是这些函数不会影响对象的变换矩阵。有时它很好(当你想让文本字段变大时,你设置了更大的宽度,并且你没有比例变化的问题),但有时不是(像你的情况)。解决方法是将该类型的对象添加为其他类型的子对象(和变换父项)或使用transformation.matrix modifications(然后记住在修改后重新应用矩阵!)。
public var fxgRect:Sprite = new Sprite();
fxgRect.addChild(new fxgrectangle());