actionscript 3 - How do I limit the area a movieclip can be dragged? -
i making interactive map in as3/flash cs6. @ moment, i've got zoom in , out, , dragged around.
but question is, how limit area map can dragged, can't see white space outside of it?
here code:
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 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; } }
the rectangle dimensions should in relation upper left corner of draggable item. if had 100x100 map , 50x50 viewable area, rectangle {x:-50, y:-50, width: 50, height:50}
Comments
Post a Comment