# Multiple Objects One Tween

**URL:** <https://forum.kirupa.com/t/multiple-objects-one-tween/191836>\
**Category:** flash\
**Created:** [June 23, 2006, 11:02am UTC](https://forum.kirupa.com/t/multiple-objects-one-tween/191836 "2006-06-23T11:02:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JimmyH](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jimmyh/32/1884_2.png) [@JimmyH](https://forum.kirupa.com/u/JimmyH)\
**Post date:** [June 23, 2006, 11:02am UTC](https://forum.kirupa.com/t/multiple-objects-one-tween/191836/1 "2006-06-23T11:02:28Z")

</div>

Hello.

Say i’ve got multiple clips on stage and i want to move them all say 20pixels to the right. I want to do this with one Tween and have a nice elegant mathematical solution (i don’t want to have to take position stamps etc etc unless its absolutely necessary). Here’s an example. 4 clips randomly dragged on the stage and put in an array, Then one tween to move them all (for performance reasons):

```auto

import mx.transitions.Tween;
import mx.transitions.easing.*;

var disTraveled = 0
var ball_array = new Array(ball0_mc, ball1_mc, ball2_mc, ball3_mc)

var obj = new Object()
obj.x = 20

var xTween = new Tween(obj, "x", Regular.easeOut, obj.x, 0, 20)
xTween.addListener(this)

function onMotionChanged(event:Object):Void
{
    var it = ball_array.length
    
    for (var i=0; i < it; i++)
    {
        ball_array*._x += obj.x
    }
    
    disTraveled += obj.x
}

function onMotionFinished(event:Object):Void
{
    trace(disTraveled)
}

```

obviously this code doesn’t work as it is iteratively adding the value of obj.x (not the val - prev val to get the difference). There must be a nice solution to this and wandered if anyone had come accross this problem before

cheers

jimmy
