0
function showpic(e:Event):void
{
    if(bitmap != null)
    {
        removeChild(bitmap);
    }

    var originalWidth:int = Bitmap(e.currentTarget.content).width;
    var originalHeight:int = Bitmap(e.currentTarget.content).height;

    bitmapdata = new BitmapData(originalWidth,originalHeight);
    bitmap = new Bitmap(bitmapdata);
    bitmap.bitmapData = Bitmap(e.currentTarget.content).bitmapData;

    bitmap.width = this.stage.stageWidth;
    bitmap.height = (originalHeight * this.stage.stageWidth) / originalWidth;

    bitmap.x = 0;
    bitmap.y = stage.stageHeight/3;

    sp = new Sprite();
    sp.addChild(bitmap);

    addChildAt(sp,0);
    }

sp.addEventListener(MouseEvent.MOUSE_DOWN, movingstart);
function movingstart(e:MouseEvent):void
{
sp.startDrag();
}

sp.addEventListener(MouseEvent.MOUSE_UP, movingstop);
function movingstop(e:MouseEvent):void
{
sp.stopDrag();
}

看!!我成功在屏幕上显示我的 sp。但是当我按下鼠标并抬起鼠标时它没有移动。

我知道位图不能接受 MouseEvent。所以我将它添加为 Sprite。

4

1 回答 1

0

尝试使用 targe 或 currentTarget 而不是 sp

于 2015-01-23T12:06:20.930 回答