简体   繁体   中英

as3/air/android/ “cameraroll and Sprite”

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();
}

look!! I succeeded display my sp on screen. but It didn't moves when I did mouse down and mouse up.

I know that bitmap couldn't take MouseEvent. so I addChild it as Sprite.

尝试使用targe或currentTarget代替sp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM