For Jubba!

Hi Jubba!

Okay, so I have a big map and an inset map. When you use the zoom slider a “frame” appears in the inset box to show where on the map you are. You can drag the frame around the inset and it updates in the big map. The problem is that it isn’t quite accurate. And if you click anywhere BUT the exact center of the frame on the inset and start dragging then the frame jumps to center on the mouse and doesn’t quite update on the big map.

I am NOT using StartDrag but rather some code I adapted from senocular’s website fla’s (www.umbc.edu/interactive).

This is the code on the inset map:

onClipEvent (load) {
    bounds = {L:-51.7, R:51.7, T:-69, B:69};
}
onClipEvent (mouseMove) {
    if (this.frame.dragging) {
                    frame._x = Math.min(Math.max(_xmouse-offset[0], bounds.L), bounds.R);
        frame._y = Math.min(Math.max(_ymouse-offset[1], bounds.T), bounds.B);
        updateAfterEvent();
    }
}
onClipEvent (load) {
    scale = 1;
}
onClipEvent (enterFrame) {
    s = 100*100/_root.scale;
    // reverse scale
    _root.map.center._x = -this.frame._x*scale;
    _root.map.center._y = -this.frame._y*scale;
    // position based on this 10% scale
    this.frame._xscale = frame._yscale=s*scale;
    // scale to reverse
}


And this is the code on the drag button underneath the inset map:

on(press){
    // set dragging of frame to true
    minimap.frame.dragging = true
    // calculate offset from center - relative to scale of map
    minimap.frame.offset = [minimap.minicenter._xmouse* 100/minimap.minicenter._xscale,minimap.minicenter._ymouse* 100/minimap.minicenter._xscale]
}
on(release,releaseOutside){
    // set dragging of map to false
    minimap.frame.dragging = false
}


The fla can be downloaded from:
www.humboldt.edu/~mgk9/Test2.fla

Any suggestions?
:nerd:

I’m not sure exactly what the problem is… you don’t want it to snap to the mouse coordinates?

anyways, i can’t really look at this until later tomorrow night. I have work all day tomorrow. Someone will probably have an answer by then.

hi!
perhaps there’s something here…

onClipEvent (enterFrame) {
    s = 100*100/_root.scale;
    // reverse scale
    _root.map.center._x = -this.frame._x*scale; //  ***  
   _root.map.center._y = -this.frame._y*scale;//***
    // position based on this 10% scale
    this.frame._xscale = frame._yscale=s*scale;
    // scale to reverse
}

***"-this.frame._x" and “-this.frame._y” should be multiplied by 5 ,
that is, the scale ratio of your small & big map…

I can’t believe it! It works! I’ve been trying to work this out for WEEKS! You guys are so rad! Thank you thank you thank you thank you thank you! Noxious you rule - I never EVER would have thought of it! And it’s so simple!

:trout:

You just made my MONTH man!

woooh :blush:

anytime! :thumb: