If L be the original length of linear path (horizontal or vertical) traversed by an object, how can I make Flash change the length according to equation y = L/x where x is an dynamic value generated?
Not entirely sure what you’re asking… do you want to change the size of an object to an arbitrary value?
I want the distance between the start and end position of a moving object to change every time a button is pressed. Do you know how to stop an object at a certain distance from its registration point?
Well… to start, you need to make note of what the start position is of the object. Make a button, and in the actions window for it you can put this code:
on(load){
xstart = myObject._x;
ystart = myObject._y;
xdistance = 10; // the distance it moves each click; you can use whatever numbers you want
ydistance = 10;
xmaxdistance = 95 + xstart; // the '95' here is the max distance you want it to move
ymaxdistance = 95 + ystart;
}
on(click){
if (myObject._x + xdistance > xmaxdistance){ // checks to see if moving it again will push it beyond your desired distance
myObject._x = maxdistance; // if it was pushed past it, set it to the max distance
}else{
myObject._x += xdistance; // moves the object to the right by 'xdistance' pixels
}
if (myObject._y + ydistance > ymaxdistance){
myObject._y = ymaxdistance;
}else{
myObject._y += ydistance;
}
}
Hope it helps!
If the distance the object moves each click be variable “value” which is the input value, can I write ydistance = value in the on(load) script?