Object control limits

i hope somone can help me with this, it is a relatively basic actionscripting question.

i have a virtual tour that i’m doing and in that i want to have controls to zoom in and out on the map as well as pan the map view so that one can effectively scroll around the map while zoomed in. i want to know how to set limits to the variables

so that i can say:

tell target
_x -= 5

while _x is less than 300

this would tell the object onPress to move left 5 pixels until it hits a value of 300

how would i set that limit in actionscript?

I’m sure there are many ways to do it, but I’d set the boundaries in variables tied to the _width and _height properties of a “placeholder” object stored on another layer.


layer1 = movieclip symbol containing a simple rectangle, with it’s visibility set to false. Name the instance, for example, limitClip

main timeline would have the boundary variables:
leftLimit = _root.limitClip._x;
rightLimit = _root.limitClip._x + _root.limitClip._width;
upperLimit = _root.limitClip._y;
lower Limit = _root.limitClip._y + _root.limitClip._height;

You can then test for the boundaries prior to executing movement code. Example:

on(press) {
if(_root.pathToObject._x <_root.rightLimit) {
_root.pathToObject._x = _root.pathToObject._x + 5;
//blah blah

Just one thought starter.

could i just say

on(press) {
if(_root.pathToObject._x < 300) {
_root.pathToObject._x = _root.pathToObject._x + 5;


then i would not need a bounding box but rather i could specify the numbers dynamically. i want to do this because when you zoom on the object it is not really a zoom but an enlargement of the object within a mask. so if the object is bigger then they may not be able to see the whole thing even by scrolling because of the boundingbox and mask.

i think i will make a sample movie illustrating exactly what i’m trying to do when i get to work tomorrow

Please do cos I don’t understand what you’re trying to do :slight_smile:

And Karen, I love your footer! Are the colors random?

pom :asian:

Sure, you could hard code the value, no problem. I like to avoid that so that future changes are easy, but with your project it makes sense. Good luck with your sample!

Thanks! :slight_smile: Yes, the colors are randomly generated. That little footer project was very fun to do!


omgosh … so cool … how do i make random colors. thatd be kinda cool to have random colors on mine … within certain limits … i dont think i want all of em … but it’d be cool to change it.

do you know whats wrong with my footer … i just made it and it looks all funny on here :slight_smile:

thx again and i will post a sample when i get to work in the morning.

nevermind … i figured my footer out … thx