开发者

How to create an interactive image panning in flash?

I'm kinda new in flash and as3 so this may not be as difficult as it looks right now. I've been trying to figure out how I can pan an image in flash (x and y). I have a movieclip and I want the user only to se开发者_Python百科e a small part as he's panning with the mouse. Hope you can help me out with this.

Thanks,

Joana


You could try this: http://as3imagepan.blogspot.com/ and download the fla's here: http://www.flashmadblog.com/wp-content/uploads/2009/11/panning_image.zip


Here's a simple solution:

var bitmapHolder:Sprite // this is your image container
var masker:Sprite = new Sprite();
masker.graphics.beginFill(0);
masker.graphics.drawRect(0, 0, width_you_want_visible, height_you_want_visible);
masker.graphics.endFill();

bitmapHolder.mask = masker;
addChild(bitmapHolder);
addChild(masker);

bitmapHolder.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);

function startDragging(e:MouseEvent):void {
 bitmapHolder.startDrag();
 stage.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
}

function stopDragging(e:MouseEvent):void {
 stage.removeEventListener(MouseEvent.MOUSE_UP, stopDragging);
 bitmapHolder.stopDrag();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜