1 Reply Latest reply on Dec 23, 2006 4:31 PM by jgn2006

    World map drag/zoom

    batmanbury
      I've created a world map with clickable countries and two buttons for zooming in and out. The clip is also draggable when clicked but there are a few aspects I want that I have no idea how to start...

      First of all, when the "zoom in" button is clicked, the movie clip simply increases in size (dont know of another way to do it), but always zooms in towards the center of the map. So, you always have to keep dragging around to get back to where you were looking. I dont want a feature that zooms wherever you click though. Simply, I need a way for the current position to be kept when zoom in/zoom out is clicked.

      Next is about the dragging... If you drag the map far enough, everything looks rather blank and you might not even be able to drag it back and have to end up refreshing the page. I'm trying to make a feature that loops the map horizontally, so one could drag endlessly...but at the same time there must be a barrier vertically. The barrier needs to work in a way that it still allows zooming in, but remains at the top and bottom when you try to drag the map up/down.

      For me, both of these ideas are difficult enough, but they also have to work in harmony with each other. I hope someone can understand how I've laid this out...

      Any script ideas would be greatly appreciated. I'm using Flash 8.

      Heres my zoom script:

      zoomin.onRelease = function():Void{
      with (world){
      _xscale += 25;
      _yscale += 25;
      }
      };

      zoomout.onRelease = function():Void{
      with (world){
      _xscale -= 25;
      _yscale -= 25;
      }
      };

      And my dragging script (basic startdrag took away button functionality for some reason):

      onClipEvent (load) {
      dragging = false;
      }

      onClipEvent (mouseDown) {
      if (this.hitTest(_root._xmouse, _root._ymouse)) {
      dragging = true;

      xOffset = this._x - _root._xmouse;
      yOffset = this._y - _root._ymouse;
      }
      }

      onClipEvent (enterFrame) {
      if (dragging) {
      this._x = _root._xmouse + xOffset;
      this._y = _root._ymouse + yOffset;
      }
      }

      onClipEvent (mouseUp) {
      if (this.hitTest(_root._xmouse, _root._ymouse)) {
      dragging = false;
      }
      }