A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: Map Scripting Help

  1. #1
    Freelance or Bust thodya's Avatar
    Join Date
    Aug 2000
    Location
    Toronto, ON
    Posts
    71

    Map Scripting Help

    Well...I'm close...I'm trying to develop a pretty simple map with scripted pan, and zoom functions.

    I've got the pan working nicely, but I'm having trouble with the zoom (getting it to zoom on center properly). I think I'm very close, just off with the math somewhere after staring at this thing for hours.

    If someone could take a peak at the code and let me know what you think it would be much appreciated. I'm sure it's something obvious, I'm just braindead from looking at this for so long.

    Zip: http://www.thodyconsulting.com/junk/mapv3.fla.zip

    Sit: http://www.thodyconsulting.com/junk/mapv3.fla.sit

    adam@thodyconsulting.com

    Cheers,
    Adam

  2. #2
    Junior Member
    Join Date
    Feb 2001
    Location
    Rhode Island
    Posts
    18
    I'm also trying to do this same thing as well. I'm making an interactive campus map for my workplace, and I'm trying to be able to do the same thing (zoom/pan)(upper righthand corner) as this website.


    http://www2.gwu.edu/~map/imap/

    Tough to find a tutorial on this subject.

  3. #3
    Freelance or Bust thodya's Avatar
    Join Date
    Aug 2000
    Location
    Toronto, ON
    Posts
    71
    No one have any ideas? I thought it would be something pretty straightforward.

  4. #4
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    It is easier to explain how i would do it rather than look through your code.

    Place your map movieClip inside a container movieClip. Then you can apply your scale commands to the container to get the zoom effect and you can pan by moving the map movieClip.

    see example...
    www.lexicon-design.co.uk
    If we aren't supposed to eat animals, then why are they made of meat?
    If Vegetarians like animals so much, why do they eat all their food?

  5. #5
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    in case you don't have mx pro here is the mx version...
    www.lexicon-design.co.uk
    If we aren't supposed to eat animals, then why are they made of meat?
    If Vegetarians like animals so much, why do they eat all their food?

  6. #6
    Freelance or Bust thodya's Avatar
    Join Date
    Aug 2000
    Location
    Toronto, ON
    Posts
    71
    Very nice! Much simpler approach, and it works. Thanks a ton for your time.

  7. #7
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    no worries, enjoy
    www.lexicon-design.co.uk
    If we aren't supposed to eat animals, then why are they made of meat?
    If Vegetarians like animals so much, why do they eat all their food?

  8. #8
    Junior Member
    Join Date
    Feb 2001
    Location
    Rhode Island
    Posts
    18
    Lexicon:

    Your Example worked great. I just can't figure out how to make a stop point or how should I say home point (where I don't want it to unzoom any more. Basically someone could keep unzooming to the point where the map would invert and then zoom. Hopefully it would be the same to make stop points for North, South, East, West as well.

    Appreciate any help
    Last edited by scottlarue; 01-18-2005 at 10:17 AM.

  9. #9
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    Here is a map demo from Senocular that is one of the better ones I have seen. It allows for zooming and has a minimap with a focus rectangle that can be dragged. I created an auto zoom that can zoom into a mouse clicked point, but it is not as effective for maps as the attached demo.

    Hope it helps
    NTD

  10. #10
    Junior Member
    Join Date
    Feb 2001
    Location
    Rhode Island
    Posts
    18
    NTD:

    That file did help some. It looks as though you can set a max zoom, so it should be reasonable to assume that min zoom would be doable as well. Normally I wouldn't mind taking my time to figure stuff like this out, but my boss went ahead and spoke of the project I was working on to the VP's so now they have given me a deadline to finish the project. (Great huh?)

    If I can't figure out a way to do it, I might use your example instead.

    Thanks
    Scott

  11. #11
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    you can simply add to the existing functions to limit their actions...

    code:

    var minScale = 50;
    var maxScale = 150;
    function scaler(){
    if((this.dir<0 && this._xscale>minScale)||(this.dir>0 && this._xscale<maxScale)){
    this._xscale = this._yscale += 10*this.dir;
    }
    }

    www.lexicon-design.co.uk
    If we aren't supposed to eat animals, then why are they made of meat?
    If Vegetarians like animals so much, why do they eat all their food?

  12. #12
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hey Lexicon,

    Your site is very nice. I remember seeing a first person view pong game you created there, but I dont see it anymore. Could you be coaxed into describing how you did it? Pretty cool game.

    Regards
    NTD

  13. #13
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    thx NTD. Man that thing is old, written in F5 i think. The code is ugly and way out of date.

    Try these for some good (up-to-date) pointers...

    http://ericlin2.tripod.com/f3d/pong3d.html

    http://www.flashkit.com/board/showth...hreadid=590887
    www.lexicon-design.co.uk
    If we aren't supposed to eat animals, then why are they made of meat?
    If Vegetarians like animals so much, why do they eat all their food?

  14. #14
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hey,

    Thanks for that! I have seen lots of ericlins stuff, but I never saw that tutorial. I have been looking into some 3d tutorials and I remembered your pong game from some time back. Yours is the only version I had seen and it was quite addictive. Anyway, thanks for the link.

    Regards
    NTD

  15. #15
    Junior Member
    Join Date
    Feb 2001
    Location
    Rhode Island
    Posts
    18
    Lex,

    That worked PERFECT! I can't thank you enough. I hate even to ask one more question but... Is there also a way so that the user would only be able to pan left,right,up,down a certain distance. I'm not sure if the zoom portion would be a factor in doing this. Either way you've been a great help.

    Here is a copy of what I'm working on. The map is almost complete, but I have a long way to go to set up buttons and other things. I'm also trying to figure out how to zoom the map on a specific building when either clicking on the building or the corresponding button.

    Excuse the disorganized library and stuff. I haven't had time to tidy every thing up.

    http://members.cox.net/scottlarue/interactivemap.fla

    Thanks
    Scott
    Last edited by scottlarue; 01-19-2005 at 07:44 AM.

  16. #16
    Freelance or Bust thodya's Avatar
    Join Date
    Aug 2000
    Location
    Toronto, ON
    Posts
    71
    This is the part I had trouble with. Although setting the max left or right at the first zoom is easy, I've been stumbling trying to set those figures based on the zoom level.

    When you're zooming in, I think the max left, for example, would be the max at 100% zoom, times the zoom factor. That part I think I have figured out.

    Where I had trouble was instances where you'd zoom in say to 3x, then pan to the boundry, then zoom out. As you zoom out, the map remains centered on the same point, as it should, so the boundry ends up being a 3rd of the way into the page. Obviously that looks bad, but I'm not too sure how to combat that from a usability standpoint. Any ideas?

    (The other issue I'm having is really choppy animation. I'm guessing this is because of the size of the map graphic/memory issues)

  17. #17
    Freelance or Bust thodya's Avatar
    Join Date
    Aug 2000
    Location
    Toronto, ON
    Posts
    71
    Actually...perhaps I'm wrong now, I forgot the map is now in a container mc. Are it's co-ordinates relative to the stage, or to it's container mc? If they're relative to the container mc I guess the coordinates would be unaffected by the zoom level.

    Although that would mean the scroll will get progressively faster as you zoom in...

  18. #18
    Junior Member
    Join Date
    Feb 2001
    Location
    Rhode Island
    Posts
    18
    For me all the buttons had to be placed on the map inside the container. Otherwise the buttons would end up being left behind and not zoomed or panned. They are invisible buttons over the buildings.

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