Groups | Blog | Home
all groups > flash actionscript > january 2006 >

flash actionscript : Scrolling Around a Large Map


MonkeyPiePdx
1/29/2006 5:39:39 PM
I have a large map in a smaller window and I want to have an up/down/left/right
button on the map for the user to be able to click to move around. I know how
to use the "on(release){mymap._x= . . . .}, but I need a couple things to
happen:

1) there needs to be a limit when the map hits the end of the boundary (when
the left side of the map hits the left edge of the window) so you can't keep
clicking on the left button and the map goes away

2) Is there a way to "slide" the map to the next position instead of it just
jumping to the next spot over?

Thanks for any help!
MonkeyPiePdx
1/29/2006 10:05:25 PM
rlc5611
1/30/2006 1:06:10 AM
You might take a look at this and see if it is helpful:

http://sierrabravocharlie.com/experimental/all_uk.swf

or the source

http://sierrabravocharlie.com/experimental/all_uk.fla

It is not scripted to ease into position but the answer to your question is
that yes you can script it to slide rather than jump. In the newer versions of
Flash, there are even built-in utilities that you might be able to use
depending on how your map is constructed in case you don't want to make your
own script.
MonkeyPiePdx
1/30/2006 2:04:07 AM
Thanks - this is pretty much what I was looking for. I'll have to look for the
sliding feature. The other thing - is there an ability to put limits on map so
you can't drag it out of the window?

Thanks
MonkeyPiePdx
1/30/2006 5:00:21 PM
muskungus
1/31/2006 4:50:04 PM
I am working on something similar and you can use startDrag/stopDrag to control
the drag.

Try placing this AS on your button or mc.

/* false = lock cursor to center of button or mc */
/* left, top, right, bottom values relative to the parent of the mc */

on (press) {
this.startDrag(false,0,0,0,0);
}

/* no paramaters for stopDrag because */
/* only one object can be dragged at a time */

on (release) {
stopDrag();
}

Hope that helps.

EW
MonkeyPiePdx
2/3/2006 1:34:59 AM
I think this will work for me. I can have the user zoom in on the map and then
let them drag it around to view different parts. I don't quite understand the
coordinates though. I want my map to stop when an edge gets to the edge of my
movie's window edge. This isn't quite working for me. Are you able to provide
an example or maybe just the simple math showing the relationship of the target
MC (1000px wide x 600 high) centered in the window and the size/dimensions of
the scene window (550px x 400px) it's in (my target MC is just up on the main
timeline, not nested or anything).

Or is there another variable here - like where the user clicks??

Thanks
AddThis Social Bookmark Button