hey,
i am trying to create a map that the user can zoom in using the scroll wheel and also follows the mouse where ever it moves...but im not aware of any way or function in AS3 that i can use, so thats my problem
any ideas? and
Printable View
hey,
i am trying to create a map that the user can zoom in using the scroll wheel and also follows the mouse where ever it moves...but im not aware of any way or function in AS3 that i can use, so thats my problem
any ideas? and
Something like this maybe?Code:stage.addEventListener(MouseEvent.MOUSE_WHEEL, zoomIt);
function zoomIt(event.MouseEvent) {
var change:int = (event.delta/3)*10;
someSpriteOrMC.scaleX+=change;
someSpriteOrMC.scaleY+=change;
}
its coming up with some error when i tried it
1084: Syntax error: expecting rightparen before dot.
lol,
event:MouseEvent, not dot!Code:stage.addEventListener(MouseEvent.MOUSE_WHEEL, zoomIt);
function zoomIt(event:MouseEvent) {
var change:int = (event.delta/6);
someSpriteOrMC.scaleX+=change;
someSpriteOrMC.scaleY+=change;
}
Also *10 might make it grow too fast....oh and for better results, try using tweens!
lol, i cant beleive i didnt notice the dot anyways....how would i be able to use tweens? also the current method only zooms into one corner, why is that?
replace the scaleX and Y parts with tween commands....I suggest looking for tween tutorials online if you don't know how to do the tweens in actionscript!
As for zooming into the corner, that's because of the origin of the movieclip, which by default, is the top-left corner! To solve this you can use a simple trick, first scale, then shift it by the scale amount.
That function was just a sample to show you where to get started on zooming with the mouse wheel, you have to modify it a lot if you want good results!