PDA

View Full Version : map goes off page



wdv
October 14th, 2005, 06:34 PM
can someone take a look at the attached .fla, i managed to create a map that moves with the keyboard arrows but now, I noticed that the map doesnt stop at the edges. if you move it to any far side it keeps going off the page. is there a action script to tell the mc to stop once it reaches the end of the map?

Any suggestions or tutorial link?

goto()
October 14th, 2005, 06:54 PM
Hey, its me again, but I feel so compromised with your map
You have got almost all code...You only have to add a ssimple code like this
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_root.map._x -= 10;
if (_root.map._x < 10) {
_root.map._x += 10;
}
}
}
with this condition you set the limit
if (_root.map._x < 10) {
with this you increase the same decrease value when mc is on the limit, so, your mc velocity is 0
_root.map._x += 10;

:thumb2: ::::::goto()::::::

wdv
October 17th, 2005, 07:02 PM
i kept getting a script error prompt

this (


on (release){
gotoAndPlay(1);
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.DOWN)) {
_root.map._y -= 25;
if (_root.map._x< 25){
}
}
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_root.map._y += 25;
if (_root.map._x< 25){
}
}
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_root.map._x += 25;
if (_root.map._x< 25){
}
}
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_root.map._x -= 25;
if (_root.map._x< 25){
}
}
}
}

TheCanadian
October 17th, 2005, 07:13 PM
onClipEvent (enterFrame) {
if (Key.isDown(Key.DOWN)) {
_root.map._y -= 10;
} else if (Key.isDown(Key.UP)) {
_root.map._y += 10;
} else if (Key.isDown(Key.LEFT)) {
_root.map._x += 10;
} else if (Key.isDown(Key.RIGHT)) {
_root.map._x -= 10;
}
if (_x < 0) {
_x = 0;
} else if (_x > 150) {
_x = 150;
}
if (_y < 0) {
_y = 0;
} else if (_y > 150) {
_y = 150;
}
}

That should do what you want :). Just play around with the values.

goto()
October 17th, 2005, 08:29 PM
Yeah, maybe separate 'clipEvents' are breaking up your code..But first, you need plus the oppositte value to stop map under the second condition.

wdv
October 18th, 2005, 02:21 AM
Thanks guys I tried both ways and couldnt seem to still figure it out, I played with the numbers but couldnt get a affect. I have re-attached the .fla with my new code, I am not getting a script error, it just still doesnt work :(, i greatly appreciate the help so far :)

nathan99
October 18th, 2005, 05:30 AM
Keep the align top edge & left edge, and youll be sweet(it will make the map automatically stop by chcking its width etc) Just make sure you have the align right!! :) (ctrl+k)

wdv
October 18th, 2005, 03:41 PM
cool works now :), thanks nathan and everyone else for helping. It seems like there are a thousand ways to do any one thing in flash. Man I need to get a action script book.