|
-
Contrain draggable/Zoomable map
trouble constraining draggable map
How to constrain draggable map w/o startdrag
i am tring to create a draggable map with dynamic zoom and drag and I want to be able to keep the map from crossing a zoom margin mc no matter how big the map gets. Here is the code i'm using some of which i got from another post:
// This is the code on my zoom in button
on (release) {
targetScale = int(ThePic._xscale + ThePic._xscale * .5);
this.onEnterFrame = scaleMap;
call(roadKiller());
call(locationKiller());
call (PosControl());
}
// on main timeline
// this zooms/scales the map
function scaleMap() {
var s = (targetScale - ThePic._xscale) * .3;
if (Math.abs(s) < 1) {
ThePic._xscale = targetScale;
ThePic._yscale = targetScale;
this.onEnterFrame = null;
} else {
ThePic._xscale += s;
ThePic._yscale += s;
}
}
// Turn Roads on and off
function roadKiller()
{
if (targetScale >= 60)
{
setProperty("_root.ThePic.roads", _visible, "1");
}
else
{
setProperty("_root.ThePic.roads", _visible, "0");
} // end if
} // End of the function
// Turn Location names on and off
function locationKiller()
{
if (targetScale > 81.25)
{
setProperty("_root.ThePic.locations", _visible, "1");
}
else
{
setProperty("_root.ThePic.locations", _visible, "0");
} // end if
} // End of the function
// On mc "ThePic" timeline
this.inertia=0.75//Number, 0=no inertia, 1=infinite inertia (imovable)
this.onPress=function(){
this.offset={x:this._xmouse, y:this._ymouse}
this.onEnterFrame=this.followMouseInertia;
}
this.onRelease=function(){
delete this.onEnterFrame;
}
this.onReleaseOutside=this.onRelease;
this.followMouseInertia=function(){
this._x+=(this._xmouse-this.offset.x)*(1-this.inertia);
this._y+=(this._ymouse-this.offset.y)*(1-this.inertia);
}
// On button inside MC
//Current constrain AS -- does not work
on(press){
//boundaries
_root.ThePic.bounds={xMin:0, xMax:200, yMin:0, yMax:200};
_root.ThePic.followMouseInertia=function(){
//calculate values
posX=ZoomMargin._x+(this._xmouse-this.offset.x)*(1-this.inertia);
posY=ZoomMargin._y+(this._ymouse-this.offset.y)*(1-this.inertia);
//constrain values
posX=Math.max(Math.min(posX,this.bounds.xMax),this .bounds.xMin)
posY=Math.max(Math.min(posY,this.bounds.yMax),this .bounds.yMin)
//move mc
this._x=posX
this._y=posY
}
}
The Problem is that i just can't seem to get it to stay within the zoomMargin mc's bounds, and i have tried a few different methods none of which were successful.
PLEASE HELP!!!!!!!!!!!!
Thanks in advance guys!
Here is a link to the map:
http://dev.emeraldcoast.com/seatown...t/flashMap.html
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|