开发者

how to drag and zoom big movieclips on flash? (like googlemaps - withouth the +- buttons)

that's about it. I want a big movieclip or image to be dragable around the screen like a map. i'm very new to actionscript so please be de开发者_StackOverflow中文版scriptive.


Option 1: Your easiest option would be to use the ScrollPane control in Flash.

You could get away with no code at all initially.

  1. Drag a ScrollPane component from the Components Panel (Ctrl+F7 on Windows/Linux /CMD+F7 on OSX)
  2. Set scrollDrag to true in the Parameters tab
  3. Input the path to a movie clip's linkage id in the ScollPane's source parameter.

Have a look at the documetation and examples.

Option 2: Use a mask:

  1. set a mask in the IDE or using actionscript to your bigMovieClip
  2. add event listeners for MOUSE_DOWN and MOUSE_UP to setup dragging

actioncript 3 required:

bigMovieClip.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);
stage.addEventListener(MouseEvent.MOUSE_UP, dragOff);

function dragOn(event:MouseEvent):void{
    event.currentTarget.startDrag();
}
function dragOff(event:MouseEvent):void{
    bigMovieClip.stopDrag();
}

Option 3: Use the scrollRect property of MovieClip

If your clip is 1000x1000 for example, and you want your visible area to be 500x500 starting from 0,0 all you need to do is

bigMovieClip.scrollRect = new Rectangle(0,0,500,500);

then when you need to scroll, you store the rectangle, modify the x or y depending on your needs and update the scrollRect

var sRect:Rectangle = bigMovieClip.scrollRect;
sRect.x += 20;
bigMovieClip.scrollRect = sRect;

Good luck

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜