我正在 as3/flash cs6 中制作交互式地图。目前,我可以放大和缩小,并被拖动。
但我的问题是,如何限制地图可以拖动的区域,所以你看不到它外面的空白?
这是我的代码:
import flash.events.MouseEvent;
function initDragger(mc:MovieClip):void
{
mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
mc.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
function mouseDownHandler(e:MouseEvent):void
{
e.currentTarget.startDrag();
}
function mouseUpHandler(e:MouseEvent):void
{
e.currentTarget.stopDrag();
}
// Set up drag
initDragger(map);
zoomIn.addEventListener(MouseEvent.CLICK, mapzoomin);
function mapzoomin(event:MouseEvent):void
{
if (map.scaleX < 10)
{
map.scaleX += 1;
map.scaleY += 1;
}
}
zoomOut.addEventListener(MouseEvent.CLICK, mapzoomout);
function mapzoomout(event:MouseEvent):void
{
if (map.scaleX > 1)
{
map.scaleX -= 1;
map.scaleY -= 1;
}
}