This is very basic and for some reason it's not working. I am doing a very basic zoom in/out map thing and I have a button where i just want to reset the map to it's original position. So on the reset button I have:
on (release) {
lowestScale = 100;// lowest desired scale of map2 in %
highestScale = 300;// highest desired scale of map2 in %
_root.position=_root.map2._x=456.3, _root.map2._y=109.8;
function reset() {
// calculates scale and sets it
_root.scale = _root.map2._xscale=_root.map2._yscale=lowestScale;
_root.slider.scrollMin = _root.range._y-_root.range._height;// minimum _y value possiible for scrollbar
_root.slider.scrollMax = _root.range._y;// maximum _y value possiible for scrollbar
_root.slider._y = _root.slider.scrollMin+(_root.slider.scrollMax-_root.slider.scrollMin)/1;// sets starting position of scrollbar (currently half-way)
scaleFactor = Math.pow(highestScale/lowestScale, 1/(_root.slider.scrollMax-_root.slider.scrollMin));// variable for SetScale
}
reset();
}
For testing I did the following but it's still didn't work:
on (release) {
_root.map2._x=456.3
_root.map2._y=109.8;
}
Any ideas as to what I am doing wrong, this is so basic it's embarrassing.
I am trying to get my head around actionscript but I think I need to take a maths class as it's all bloody formulas! Anyway, I couldn't attach because file was too large but here is the file I put on the server:
I took a look at it and there were few problems. Please, I hope you don't mind me having changed it a bit. I never did that type of project before and felt it was fun to take a look at. So, the major problem I saw with the map is that when you would scale it, the center point did not remain in the center. So, what ever you are looking at is moving out of the screen when you are zooming in. So, in order to solve this, we have to calculate where the center point will be as we zoom in and move the map accordingly. The second problem was when you are panning the map while zoomed in and later on change the zoom factor again. So, we have to calculate the unzoomed center point as you pan the map.
Resetting the map with the reset button was then as simple as resetting the map coordinates and zoom factor.
P.S. I also had to change the register point in the map. It made things a lot simpler, especially with the math
P.P.S I also realize that I did not include the bounding while panning the map. You just have to add the dounding box in the startDrag function. Make sure that the bounding box size is scaled with the scale factor.
No of course I don't mind you messing with the file and having fun with it. I THANK YOU!!! Smarty Pants
I'll admit I am more of a flash designer than a programmer and it's just getting too complicated for me! I left the bounds thing out... I couldn't put it back in and your code is great. Thanks so much.
Cheers!
Last edited by Shmeed4020; 01-21-2008 at 01:36 PM.
WOW, that's impressive, 11 years old and you're working in flash! Man I feel old. Or you've been working in flash for 11 years?! You're probably getting that error because you don't have the latest version of flash? What flash version are you using if it's less than flash 8 you won't be able to open it up....good luck!
Good for you! Well it's mighty impressive! You'll be a pro in no time! I've saved that file down (we're using CS3) for you so you can have a look at it and hopefully get something out of it. ENJOY!