A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: How to properly code a pan & zoom function

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    6

    Unhappy How to properly code a pan & zoom function

    I am using Adobe Flash Professional CS5, and Actionscript 1&2.

    I'm making a map that has tooltips pop-up when you hover over various areas... I'm very much a newbie, and I'm trying to teach myself flash as I make this rather complicated project... so please bear with me.

    I want to be able to zoom in on the map, and then, once zoomed in, to be able to pan around the map by dragging (like a Hand Tool). However, I've encountered some problems, as I have no idea whatsoever how to properly do either of those things.

    For the zooming, I put a button in either corner: a zoom out icon, and a zoom in icon. For the zoom-in icon, I used the code

    on (rollOver){
    setProperty ("BG", _xscale, "200");
    setProperty ("BG", _yscale, "200");
    }

    (BG being the name of the instance used for the background of the map, which is a movie clip.)
    Now, this zooms me in well to one corner, but then i still can't drag, and another problem I've found is that the tooltips did not scale with the background; they still show up if you hover over where they would have been. So, how do I properly do this?
    The code for zoom-out is the same, only switching back to 100. I do like how the zoom in and out icons stay in the corners no matter what, though, so I need a way to keep the tooltip buttons with the parent BG, but not the zoom icons.

    And as for dragging and panning, I've looked everywhere for a simple tutorial, but I haven't found one. I've tried adapting several different source codes to do what I want, but I'm afraid I'm rather out of my depth.

    Would somebody mind taking the time to outline step-by-step, in simple terms, how I can achieve what I want?

  2. #2
    Junior Member
    Join Date
    Aug 2010
    Posts
    6
    Well, I figured out how to get the tooltips to stay assigned to their correct places at least, I think. I wasn't putting them nested within the BG movie clip before, which was silly of me. So that's solved, but I'm still pretty lost on everything else.

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    6
    So, looking over this again, basically all I'm looking for is for some piece of code that will trigger when I zoom in that allows me to drag to pan/scroll around the stage (not to drag the background itself), that can be untriggered when I zoom out.

  4. #4
    Junior Member
    Join Date
    Aug 2010
    Posts
    6
    I would be happy with something that works like the first example on this page, if someone could explain how I would go about making it work. I am unfamiliar with how classes are used.
    Last edited by thexerox123; 08-10-2010 at 03:53 PM.

Tags for this Thread

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