I have an aerial photograph which takes up the whole window and is a movieClip called map_mc.
I have two listeners that mean the user can drag the image around in the window to see more of it. I also have a zoom button which makes the movieClip bigger and therefore allows the user to zoom into a section and drag it around within the window to see different parts much like google maps.
My problem is the user can drag the movieClip too far exposing the white background. I added a bit of code to stop the user dragging it too far down using 0,0 top left corner but I can do this for the bottom right as the movieClip changes sizes and so isn't a constant.
Any ideas how I could stop this from happening? my code is below
Actionscript Code:
import flash.events.Event;
zoom20.addEventListener(MouseEvent.CLICK,zoomIn);
back.addEventListener(MouseEvent.CLICK,backOut);
map_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
map_mc.addEventListener(MouseEvent.MOUSE_UP, drop);
stage.addEventListener(Event.ENTER_FRAME,noWhite);
//var rectangle:Rectangle = new Rectangle(0,0,1920,1080);
function zoomIn(e:MouseEvent):void
{
map_mc.scaleX += .2;
map_mc.scaleY += .2;
}
function backOut(e:MouseEvent):void
{
map_mc.width = 1920;
map_mc.height = 1275.50;
map_mc.x = 0;
map_mc.y = -180.10;
}
function drag(e:MouseEvent)
{
e.target.startDrag();
}
function drop(e:MouseEvent)
{
e.target.stopDrag();
}
function noWhite(e:Event)
{
if (map_mc.y > 0)
{
map_mc.y = 0;
}
if (map_mc.x > 0)
{
map_mc.x = 0;
}
}
//()
I've done a similar thing with a rectangle zone before but that was keeping an object within the zone on stage where as with this I have things in and out of the zone.