A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: Zoom+Pan

Hybrid View

  1. #1
    Junior Member
    Join Date
    Mar 2007
    Posts
    4
    try this inside of a button

    on (press) {
    speed = 95;
    movie._x -= speed;
    }

    Also note that by changing the "-" to a "+" will change direction that it moves the object. And by using a movie._Y would produce up and down movment.

    That's all kinda common sense info.. but didn't want to leave you hanging if you didn't know.

    Let me know how it works.

    -alloy.

  2. #2
    Junior Member
    Join Date
    Jan 2001
    Posts
    25
    Does anyone know how to convert this code to use a mouse click and centers map at zoomed level? [SAME ZIP FILE AS ABOVE].

    _______________

    // size of stage
    SW = Stage.width;
    SH = Stage.height;

    // size of large map
    MW = map_mc._width;
    MH = map_mc._height;

    // Movement speed
    SPEED = .2;

    // Points of Interest
    // x,y radius, name
    poi = [{x:971,y:54,r:60,n:"Grace Cathedral"},
    {x:461,y:502,r:80,n:"Moscone Center"},
    {x:311,y:384,r:64,n:"Union Square"},
    {x:665,y:146,r:64,n:"World Trade Center"},
    {x:428,y:148,r:64,n:"Transamerica Bldg"}
    ];

    // Zoom-in Amount
    zoomAmt = 100; // additional zoom
    feedback_txt.autoSize = true;

    // This function keeps the target centered on zero,zero on submap_mc.
    // This is done so that when we zoom, the zoom stays centered around
    // the target
    //
    map_mc.submap_mc.onEnterFrame = function()
    {
    mapx = MW*_root._xmouse/SW;
    mapy = MH*_root._ymouse/SH;
    this.tx = 0 - mapx;
    this.ty = 0 - mapy;
    // _root.feedback_txt.text = mapx + ", " + mapy;
    this._x += (this.tx-this._x)*SPEED;
    this._y += (this.ty-this._y)*SPEED;
    // for 'exact' positioning, use this instead
    // this._x = this.tx;
    // this._y = this.ty;
    }

    // This keeps the map centered under the mouse
    // and scales it based on proximity to Moscone center
    map_mc.onEnterFrame = function()
    {
    this._x = _root._xmouse;
    this._y = _root._ymouse;

    var dx = zoomX - mapx;
    var dy = zoomY - mapy;

    // find a nearby point of interest
    var p = -1;
    var dist;
    for (var i = 0; i < poi.length; ++i)
    {
    var dx = poi[i].x - mapx;
    var dy = poi[i].y - mapy;
    dist = Math.sqrt(dx*dx+dy*dy);
    if (dist < poi[i].r) {
    p = i;
    break;
    }
    }
    if (p != -1) // did we get one? zoom in & show the name
    {
    var zoom = 100+zoomAmt-zoomAmt*dist/poi[p].r;
    this._xscale = this._yscale = zoom;
    feedback_txt.text = poi[p].n;
    }
    else { // otherwise, don't zoom in
    this._xscale = this._yscale = 100;
    feedback_txt.text = "";
    // uncomment the following line to see the coordinates
    feedback_txt.text = Math.floor(mapx) + ", " + Math.floor(mapy);
    }
    };

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center