# Stretching or shrinking the length traversed by object

**URL:** <https://forum.kirupa.com/t/stretching-or-shrinking-the-length-traversed-by-object/185205>\
**Category:** flash\
**Created:** [April 11, 2006, 6:34pm UTC](https://forum.kirupa.com/t/stretching-or-shrinking-the-length-traversed-by-object/185205 "2006-04-11T18:34:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bachchun](https://avatars.discourse-cdn.com/v4/letter/b/e56c9b/32.png) [@bachchun](https://forum.kirupa.com/u/bachchun)\
**Post date:** [April 11, 2006, 6:34pm UTC](https://forum.kirupa.com/t/stretching-or-shrinking-the-length-traversed-by-object/185205/1 "2006-04-11T18:34:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![FizixMan](https://avatars.discourse-cdn.com/v4/letter/f/e9c0ed/32.png) [@FizixMan](https://forum.kirupa.com/u/FizixMan)\
**Post date:** [April 11, 2006, 6:38pm UTC](https://forum.kirupa.com/t/stretching-or-shrinking-the-length-traversed-by-object/185205/2 "2006-04-11T18:38:57Z")

</div>

Not entirely sure what you’re asking… do you want to change the size of an object to an arbitrary value?

---

<div class="post-metadata">

**Author:** ![bachchun](https://avatars.discourse-cdn.com/v4/letter/b/e56c9b/32.png) [@bachchun](https://forum.kirupa.com/u/bachchun)\
**Post date:** [April 11, 2006, 9:57pm UTC](https://forum.kirupa.com/t/stretching-or-shrinking-the-length-traversed-by-object/185205/3 "2006-04-11T21:57:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![FizixMan](https://avatars.discourse-cdn.com/v4/letter/f/e9c0ed/32.png) [@FizixMan](https://forum.kirupa.com/u/FizixMan)\
**Post date:** [April 12, 2006, 1:32pm UTC](https://forum.kirupa.com/t/stretching-or-shrinking-the-length-traversed-by-object/185205/4 "2006-04-12T13:32:43Z")

</div>

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:

```auto

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!

---

<div class="post-metadata">

**Author:** ![bachchun](https://avatars.discourse-cdn.com/v4/letter/b/e56c9b/32.png) [@bachchun](https://forum.kirupa.com/u/bachchun)\
**Post date:** [April 13, 2006, 1:37pm UTC](https://forum.kirupa.com/t/stretching-or-shrinking-the-length-traversed-by-object/185205/5 "2006-04-13T13:37:53Z")

</div>

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?
