# AttachMovie question

**URL:** <https://forum.kirupa.com/t/attachmovie-question/259924>\
**Category:** Uncategorized\
**Created:** [May 10, 2008, 6:19am UTC](https://forum.kirupa.com/t/attachmovie-question/259924 "2008-05-10T06:19:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![carpenter](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@carpenter](https://forum.kirupa.com/u/carpenter)\
**Post date:** [May 10, 2008, 6:19am UTC](https://forum.kirupa.com/t/attachmovie-question/259924/1 "2008-05-10T06:19:59Z")

</div>

Hello,  
first of all, I must thank Kirupa for the wonderful greeting:  
I’ve never seen anything similar 🙂

This is an AS2/Flash8-related question.

I use this code to attach some movieclips:

sPoint = 50;  
//  
for (i=0; i\<10; i++) {  
var num = i == 0 ? sPoint : sPoint+i_this[“s”+(i-1)].\_width;  
\_root.attachMovie(“duplicand”, “s”+i, i, {initPos:num, dist:dists_});  
\_root[“s”+i].\_x = 50+i\*this[“s”+i].\_width;  
\_root[“s”+i].\_y = 100;  
}

In the initObject I put:  
+initPos: it stores informations about the clip \_x position;  
+dist: follow this post and you will know 😛

I’m duplicating points: these points are subway stations.  
In a real world scenario, distances between stations are every time different.

So, I built this array of distances values:  
dists = [223,334,12,145,45,87,56,67,78,34];

dists[0] is the distance between the first and the second station and so on.

When I duplicate the clips, there’s no need to show this distance:  
the stations must appear at the same distance.

BUT, I made an horizontal slider and what I want is the following:

when i drag the slider left-to-right all the movieclips must proportionally (remember “dist”?) change their positions, proportionally respecting their distances. When I drag the slider right-to-left they must approach, reaching their initial position in the end.

It is not important they scale onEnterFrame: it is right for me this onRelease:

slider.btn.onRelease = slider.btn.onReleaseOutside=function () {  
stopDrag();  
\_global.val = Math.floor(this.\_x/2);  
var cf = Math.floor(val/10);

```
// ALL MY PROBLEM IN THE END IS THIS LINE:

for (i=0; i&lt;11; i++) {
    _root["s"+i]._x = _root["s"+(i-1)].initPos+_root["s"+i].dist*i*cf;

}

```

};

How can I do what I’m trying to do?

Thanks!
