dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Scroll Wheel Zoom Problem

  1. #1
    Member
    Join Date
    Jun 2009
    Posts
    30

    Scroll Wheel Zoom Problem

    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
    Last edited by JT1; 09-12-2009 at 05:48 PM.

  2. #2
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,379
    Code:
    stage.addEventListener(MouseEvent.MOUSE_WHEEL, zoomIt);
    
    function zoomIt(event.MouseEvent) {
    var change:int = (event.delta/3)*10;
    someSpriteOrMC.scaleX+=change;
    someSpriteOrMC.scaleY+=change;
    }
    Something like this maybe?
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  3. #3
    Member
    Join Date
    Jun 2009
    Posts
    30
    its coming up with some error when i tried it

    1084: Syntax error: expecting rightparen before dot.

  4. #4
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    lol,
    Code:
    stage.addEventListener(MouseEvent.MOUSE_WHEEL, zoomIt);
    
    function zoomIt(event:MouseEvent) {
    var change:int = (event.delta/6);
    someSpriteOrMC.scaleX+=change;
    someSpriteOrMC.scaleY+=change;
    }
    event:MouseEvent, not dot!
    Also *10 might make it grow too fast....oh and for better results, try using tweens!
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  5. #5
    Member
    Join Date
    Jun 2009
    Posts
    30
    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?

  6. #6
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    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!
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center