分享
 
 
 

Flash实例:模仿Acdsee浏览图片的效果

王朝other·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

今天帮别人解决一个地图的问题,顺便就做了这个效果。

所有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

ctrlbtn0.duplicateMovieClip("ctrlbtn"+i, i);

}

for (i=0; 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

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

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 && _xmousestageT && _ymouse

if (actionLabel == "放大" || actionLabel == "缩小") {

box_x = _xmouse;

box_y = _ymouse;

createEmptyMovieClip("box_mc", btnNameLen+1);

with (box_mc) {

lineStyle(1, 0xff0000, 80);

moveTo(0, 0);

lineTo(0, 1000);

lineTo(1000, 1000);

lineTo(1000, 0);

lineTo(0, 0);

_width = 1;

_height = 1;

}

mapW = map_mc._width;

mapH = map_mc._height;

box_mc.onEnterFrame = function() {

this._width = Math.abs(_xmouse-box_x);

this._height = Math.abs(_ymouse-box_y);

this._x = _xmouse

this._y = _ymouse

};

}

if (actionLabel == "移动") {

left = stageR-map_mc._width;

top = stageB-map_mc._height;

right = 0;

bottom = 0;

map_mc.startDrag(false, left, top, right, bottom);

}

}

};

mouseObj.onMouseUp = function() {

if (box_mc != undefined) {

boxW = box_mc._width+box_mc._x>stageR ? stageR-box_mc._x : box_mc._width;

boxH = box_mc._height+box_mc._y>stageB ? stageB-box_mc._y : box_mc._height;

mouseX = box_mc._width != 0 ? box_mc._x : _xmouse;

mouseY = box_mc._height != 0 ? box_mc._y : _ymouse;

if (actionLabel == "放大") {

large();

}

if (actionLabel == "缩小") {

small();

}

box_mc.removeMovieClip();

}

if (actionLabel == "移动") {

map_mc.stopDrag();

}

};

function large() {

_l1 = boxW == 0 ? 1.2 : stageR/boxW;

_l2 = boxH == 0 ? 1.2 : stageB/boxH;

point = _l1<_l2 ? _l1 : _l2;

var mapx = ((mouseX+_xmouse)/2-map_mc._x)/mapScale;

var mapy = ((mouseY+_ymouse)/2-map_mc._y)/mapScale;

if (map_mc._xscale

if (mapScale*point

mapZoom(mapScale*point, mapx, mapy);

} else {

mapZoom(maxZoom, mapx, mapy);

}

}

}

function small() {

_l1 = boxW == 0 ? 0.8 : boxW/stageR;

_l2 = boxH == 0 ? 0.8 : boxH/stageB;

point = _l1>_l2 ? _l1 : _l2;

var mapx = (_xmouse-map_mc._x)/mapScale;

var mapy = (_ymouse-map_mc._y)/mapScale;

if (map_mc._xscale>minZoom) {

if (mapScale*point>minZoom) {

mapZoom(mapScale*point, mapx, mapy);

} else {

mapZoom(minZoom, mapx, mapy);

}

}

}

function mapZoom(map_scale, map_x, map_y) {

map_mc._xscale = map_scale;

map_mc._yscale = map_scale;

mapScale = map_scale;

map_mc._x = (stageL+stageR)/2-map_x*mapScale;

map_mc._y = (stageT+stageB)/2-map_y*mapScale;

//---------------------------------------------------

map_mc._x = map_mc._x+map_mc._width

map_mc._x = map_mc._x>0 ? 0 : map_mc._x;

map_mc._y = map_mc._y+map_mc._height

map_mc._y = map_mc._y>0 ? 0 : map_mc._y;

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有