![]() |
|
||||||||||
|
|||||
|
Регистрация: Mar 2010
Сообщений: 34
|
Есть карта.Все работает прекрасно вот только заказчик попросил чтоб ползунок приближения работал с помощью ползунка мыши. вот код самой работы
stageW = 982; stageH = 566; minimapWidth = 100; zoomFactor = 20; tweenSpeed = 3; alphaSpeed = 5; moveAmount = 20; zoomAmount = 3; cropWidth = stageW; cropHeight = stageH; destAlpha = 0; ID = 0; // Set the mousewheel scroll speed here scrollSpeed = 10 var mouseListener:Object = new Object(this); mouseListener.onMouseWheel = function(wheelNum:Number) { if (scroll_mc.scrollBttn._y>=scroll_mc.scrollBttn.originY) { scroll_mc.scrollBttn._y -= (wheelNum/scrollRatio)*scrollSpeed; if (scroll_mc.scrollBttn._y<scroll_mc.scrollBttn.originY) { scroll_mc.scrollBttn._y = scroll_mc.scrollBttn.originY; } else if (scroll_mc.scrollBttn._y>scroll_mc.scrollBttn.originY+scroll_mc.scrollBar._height-scroll_mc.scrollBttn._height) { scroll_mc.scrollBttn._y = scroll_mc.scrollBttn.originY+scroll_mc.scrollBar._height-scroll_mc.scrollBttn._height; } } if (scroll_mc.scrollBttn._y>scroll_mc.scrollBttn.maxY) { scroll_mc.scrollBttn._y = scroll_mc.scrollBttn.maxY; } }; Mouse.addListener(mouseListener); // // SCROLL BAR PRESS // cursor_mc._visible = false; holder_mc._alpha = 0; minimap_mc._alpha = 0; bttn.enabled = false; tweenImage = function () { holder_mc._alpha = holder_mc._alpha+((destAlpha-holder_mc._alpha)/alphaSpeed); minimap_mc._alpha = holder_mc._alpha; holder_mc.holder._x = holder_mc.holder._x+((holder_mc.marker._x-holder_mc.holder._x)/tweenSpeed); holder_mc.holder._y = holder_mc.holder._y+((holder_mc.marker._y-holder_mc.holder._y)/tweenSpeed); holder_mc._xscale = holder_mc._xscale+((destScale-holder_mc._xscale)/tweenSpeed); holder_mc._yscale = holder_mc._xscale; }; duplicateImage = function (_arg2, _arg3) { var _local1 = new flash.display.BitmapData(_arg2._width, _arg2._height); _local1.draw(_arg2); _arg3.attachBitmap(_local1, 1, true, true); }; loadImage = function () { bttn.enabled = false; var _local1 = new Color(bg_mc); setColour = "0x"+Colour[ID]; _local1.setRGB(setColour); holder_mc._alpha = 0; destAlpha = 0; scroll_mc.scrollBttn._x = 0; holder_mc.holder.loadMovie(Image[ID]); }; imageLoaded = function () { duplicateImage(holder_mc.holder, holder_mc.holder); duplicateImage(holder_mc.holder, minimap_mc.holder); minimap_mc.holder._width = minimapWidth; minimap_mc.holder._yscale = minimap_mc.holder._xscale; minimap_mc.frame_mc._width = (minimap_mc.mask_mc._width=minimap_mc.holder._width); minimap_mc.frame_mc._height = (minimap_mc.mask_mc._height=minimap_mc.holder._height); ratioWidth = holder_mc.holder._width/minimap_mc._width; ratioHeight = holder_mc.holder._height/minimap_mc._height; minimap_mc.win_mc.win._width = cropWidth/ratioWidth; minimap_mc.win_mc.win._height = cropHeight/ratioHeight; imageWidth = holder_mc.holder._width; imageHeight = holder_mc.holder._height; holder_mc.holder._x = (-imageWidth)/2; holder_mc.holder._y = (-imageHeight)/2; holder_mc.marker._x = holder_mc.holder._x; holder_mc.marker._y = holder_mc.holder._y; holder_mc._x = cropWidth/2; holder_mc._y = cropHeight/2; scroll_mc.scrollBttn._x = 0; holder_mc._height = cropHeight/zoomFactor; holder_mc._xscale = holder_mc._yscale; minScale = holder_mc._xscale; destAlpha = 100; bttn.enabled = true; }; minimap_mc.onPress = function() { holder_mc.marker._x = -minimap_mc.holder._xmouse; holder_mc.marker._y = -minimap_mc.holder._ymouse; }; bttnLeft.arrow_mc.arrow._rotation = -90; bttnBttm.arrow_mc.arrow._rotation = -180; bttnRight.arrow_mc.arrow._rotation = 90; bttnLeft.bttn.onPress = function() { bttnLeft.onEnterFrame = function() { if (holder_mc.marker._x<0) { holder_mc.marker._x = holder_mc.marker._x+moveAmount; } }; }; bttnLeft.bttn.onRelease = (bttnLeft.bttn.onReleaseOutside=function () { delete bttnLeft.onEnterFrame; }); bttnTop.bttn.onPress = function() { bttnTop.onEnterFrame = function() { if (holder_mc.marker._y<0) { holder_mc.marker._y = holder_mc.marker._y+moveAmount; } }; }; bttnTop.bttn.onRelease = (bttnTop.bttn.onReleaseOutside=function () { delete bttnTop.onEnterFrame; }); bttnBttm.bttn.onPress = function() { bttnBttm.onEnterFrame = function() { if (holder_mc.marker._y>(-imageHeight)) { holder_mc.marker._y = holder_mc.marker._y-moveAmount; } }; }; bttnBttm.bttn.onRelease = (bttnBttm.bttn.onReleaseOutside=function () { delete bttnBttm.onEnterFrame; }); bttnRight.bttn.onPress = function() { bttnRight.onEnterFrame = function() { if (holder_mc.marker._x>(-imageWidth)) { holder_mc.marker._x = holder_mc.marker._x-moveAmount; } }; }; bttnRight.bttn.onRelease = (bttnRight.bttn.onReleaseOutside=function () { delete bttnRight.onEnterFrame; }); bttnReset.bttn.onPress = function() { holder_mc.marker._x = holder_mc.holder._x; holder_mc.marker._y = holder_mc.holder._y; scroll_mc.scrollBttn._x = 0; }; bttnMinus.bttn.onPress = function() { bttnMinus.onEnterFrame = function() { if (scroll_mc.scrollBttn._x>zoomAmount) { scroll_mc.scrollBttn._x = scroll_mc.scrollBttn._x-zoomAmount; } else { scroll_mc.scrollBttn._x = 0; } }; }; bttnMinus.bttn.onRelease = (bttnMinus.bttn.onReleaseOutside=function () { delete bttnMinus.onEnterFrame; }); bttnPlus.bttn.onPress = function() { bttnPlus.onEnterFrame = function() { if (scroll_mc.scrollBttn._x<(100-zoomAmount)) { scroll_mc.scrollBttn._x = scroll_mc.scrollBttn._x+zoomAmount; } else { scroll_mc.scrollBttn._x = 163; } }; }; bttnPlus.bttn.onRelease = (bttnPlus.bttn.onReleaseOutside=function () { delete bttnPlus.onEnterFrame; }); bttn.onPress = function() { cursor_mc.gotoAndStop(2); holder_mc.marker.startDrag(false, -imageWidth, -imageHeight, 0, 0); }; bttn.onRelease = (bttn.onReleaseOutside=function () { cursor_mc.gotoAndStop(1); stopDrag(); }); bttn.onRollOver = function() { cursor_mc._visible = true; Mouse.hide(); }; bttn.onRollOut = (bttn.onDragOut=function () { cursor_mc._visible = false; Mouse.show(); }); scroll_mc.scrollBttn.onPress = function() { this.startDrag(0, 0, 0, 163, 0); }; scroll_mc.scrollBttn.onRelease = (scroll_mc.scrollBttn.onReleaseOutside=function () { this.stopDrag(); }); scroll_mc.gridBttn.onPress = function() { scroll_mc.scrollBttn._x = scroll_mc._xmouse-(scroll_mc.scrollBttn._width/2); if (scroll_mc.scrollBttn._x>100) { scroll_mc.scrollBttn._x = 100; } else if (scroll_mc.scrollBttn._x<(scroll_mc.scrollBttn._width/2)) { scroll_mc.scrollBttn._x = 0; } }; onEnterFrame = function () { destScale = (scroll_mc.scrollBttn._x+minScale)*zoomFactor; if (destScale == (minScale*zoomFactor)) { holder_mc.marker._x = (-imageWidth)/2; holder_mc.marker._y = (-imageHeight)/2; } ratioScale = holder_mc._xscale/minimap_mc._xscale; minimap_mc.win_mc._width = minimapWidth/(holder_mc._width/cropWidth); minimap_mc.win_mc._height = minimap_mc.holder._height/(holder_mc._height/cropHeight); minimap_mc.win_mc.win._x = (-(holder_mc.holder._x/ratioWidth))*ratioScale; minimap_mc.win_mc.win._y = (-(holder_mc.holder._y/ratioHeight))*ratioScale; loading = holder_mc.holder.getBytesLoaded(); filesize = holder_mc.holder.getBytesTotal(); percentage = Math.round((loading/filesize)*100); if (isNaN(percentage)) { percentage = 0; } preloader_mc.txt.text = ("LOADING "+percentage)+"%"; preloader_mc._alpha = 100-holder_mc._alpha; cursor_mc._x = _root._xmouse; cursor_mc._y = _root._ymouse; tweenImage(); }; construct = function () { i = 0; while (i<total) { Image[i] = xmlNode.childNodes[i].attributes.Image; Name[i] = xmlNode.childNodes[i].attributes.Name; Colour[i] = xmlNode.childNodes[i].attributes.Colour; select_mc.selectBttn_mc.selectBttn.duplicateMovieClip("selectBttn"+i, i); select_mc.selectBttn_mc["selectBttn"+i]._y = ((-select_mc.selectBttn_mc.selectBttn._height)-1)-(select_mc.selectBttn_mc.selectBttn._height*i); select_mc.selectBttn_mc["selectBttn"+i].txt_mc.txt.text = Name[i]; select_mc.selectBttn_mc["selectBttn"+i].ID = i; i++; } select_mc.selectShow.txt_mc.txt.text = Name[ID]; loadImage(); }; loadXML = function (_arg2) { if (_arg2) { xmlNode = this.firstChild; Image = []; Name = []; Colour = []; total = xmlNode.childNodes.length; construct(); } else { trace("Error loading XML"); } }; xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = loadXML; xmlData.load("content.xml"); stop(); |
|
|||||
|
блогер
Регистрация: Feb 2008
Адрес: Россия, Новосибирск, Академгородок
Сообщений: 2,113
Записей в блоге: 1
|
new Object(this) ... bttnRight.bttn.onRelease = (bttnRight.bttn.onReleaseOutside=function () { delete bttnRight.onEnterFrame; }); А по вопросу — сложно разобраться, что у вас в коде происходит.
__________________
hauts.ru |
|
|||||
|
Регистрация: Mar 2010
Сообщений: 34
|
Да код написан под другую игрушку не охотно было разбирать вот и поставил как есть.(В принципе я и не ахти во AS так что и разобраться было бы очень сложно) По началу этот код был предназначен для просмотра больших изображений а я его под себя сделал. У меня там есть код который вроде отвечает за прокрутку
// Set the mousewheel scroll speed here scrollSpeed = 10 var mouseListener:Object = new Object(this); mouseListener.onMouseWheel = function(wheelNum:Number) { if (scroll_mc.scrollBttn._y>=scroll_mc.scrollBttn.originY) { scroll_mc.scrollBttn._y -= (wheelNum/scrollRatio)*scrollSpeed; if (scroll_mc.scrollBttn._y<scroll_mc.scrollBttn.originY) { scroll_mc.scrollBttn._y = scroll_mc.scrollBttn.originY; } else if (scroll_mc.scrollBttn._y>scroll_mc.scrollBttn.originY+scroll_mc.scrollBar._height-scroll_mc.scrollBttn._height) { scroll_mc.scrollBttn._y = scroll_mc.scrollBttn.originY+scroll_mc.scrollBar._height-scroll_mc.scrollBttn._height; } } if (scroll_mc.scrollBttn._y>scroll_mc.scrollBttn.maxY) { scroll_mc.scrollBttn._y = scroll_mc.scrollBttn.maxY; } }; Mouse.addListener(mouseListener); // |
|
|||||
|
Регистрация: Apr 2009
Сообщений: 104
|
var mouseListener:Object = new Object();
Mouse.addListener(_root); _root.onMouseWheel = function(delta:Number, object:MovieClip):Void { mapp._yscale += delta; mapp._xscale += delta; }; |
![]() |
![]() |
Часовой пояс GMT +4, время: 18:48. |
|
|
« Предыдущая тема | Следующая тема » |
|
|