日期:2013-12-08  浏览次数:20603 次

  今天帮别人处理一个地图的问题,顺便就做了这个效果。现把原文件共享出来,有需求的可以下载。

http://www.flash8.net/bbs/UploadFile/2005-7/200578181657650.swf

点击这里下载源文件

所有as代码如下:
//---------------------------------------------
Stage.showMenu = false;
Stage.scaleMode = "noScale";
fscommand(allowscale, true);
mapScale = map_mc._xscale;
stageL = 0;
stageT = 0;
stageR = map_mc._width;
stageB = map_mc._height;
stageW = mask_mc._width;
stageH = mask_mc._height;
maxZoom = 800;
minZoom = 50;
initMapZoom();
actionLabel = "放大";
_root.onLoad = function() {
var btnName = new Array();
btnName = Array("放大", "缩小", "全图", "加大", "减小", "挪动");
btnNameLen = btnName.length;
for (i=1; i<btnNameLen; i++) {
ctrlbtn0.duplicateMovieClip("ctrlbtn"+i, i);
}
for (i=0; i<btnNameLen; i++) {
ctrlbtns = eval("ctrlbtn"+i);
ctrlbtns.btn_name.text = btnName[i];
ctrlbtns._x = i*(ctrlbtn0._width+5)+10;
ctrlbtns._y = ctrlbtn0._y;
ctrlbtns.vars = btnName[i];
ctrlbtns.onRollOver = function() {
this._alpha = 60;
};
ctrlbtns.onRollOut = function() {
this._alpha = 100;
};
ctrlbtns.onRelease = function() {
actionLabel = this.vars;
if (this.vars == "全图") {
initMapZoom();
}
if (this.vars == "加大") {
var mapx = ((stageL+stageR)/2-map_mc._x)/mapScale;
var mapy = ((stageT+stageB)/2-map_mc._y)/mapScale;
if (mapScale*1.2<maxZoom) {
mapZoom(mapScale*1.2, mapx, mapy);
} else {
mapZoom(maxZoom, mapx, mapy);
}
}
if (this.vars == "减小") {
var mapx = ((stageL+stageR)/2-map_mc._x)/mapScale;
var mapy = ((stageT+stageB)/2-map_mc._y)/mapScale;
if (mapScale*.8>minZoom) {
mapZoom(mapScale*.8, mapx, mapy);
} else {
mapZoom(minZoom, mapx, mapy);
}
}
};
}
};
function initMapZoom() {
var msW = map_mc._width/stageW;
var msH = map_mc._height/stageH;
var mapBi = (msW<msH) ? msW : msH;
map_mc._x = stageL;
map_mc._y = stageT;
mapScale = mapScale/mapBi;
map_mc._xscale = mapScale;
map_mc._yscale = mapScale;
}
var mouseObj = new Object();
Mouse.addListener(mouseObj);
mouseObj.onMouseDown = function() {
if (_xmouse>stageL && _xmouse<stageR && _ymouse>stageT && _ymouse<stageB) {
if (actionLabel == "放大" || actionLabel == "缩小") {