# Animation and function, controlling \_x and \_y

**URL:** <https://forum.kirupa.com/t/animation-and-function-controlling--x-and--y/227120>\
**Category:** flash\
**Created:** [May 27, 2007, 9:21am UTC](https://forum.kirupa.com/t/animation-and-function-controlling--x-and--y/227120 "2007-05-27T09:21:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Theofiel](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@Theofiel](https://forum.kirupa.com/u/Theofiel)\
**Post date:** [May 27, 2007, 9:21am UTC](https://forum.kirupa.com/t/animation-and-function-controlling--x-and--y/227120/1 "2007-05-27T09:21:46Z")

</div>

Hi Kirupaneers,

Have been struggeling for days now :jail:, I have in the \_root a function called elastic and then on the stage a movieclip containing 9 smaller clips called t1 --\> t9, these movieclips are each at a different y-axis and when this function is called they appear (slide) in, but now I want to slide in t1–\>t4 at \_x = 200 and t6–\>t9 at \_x=400, how can i do this within this function/code??

Thanks

```auto

mc = ["t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9"];
var i = 0;
while (i < mc.length)
{
    eval(mc*)._x = -200;
   ++i;
} // end while
j = 0;
id = setInterval(function ()
{
    if (j < mc.length)
    {
        _root.Elastic(eval(mc[j++]), "_x", 200, 6.000000E-001, 4.500000E-001, 0);
    }
    else
    {
        clearInterval(id);
    } // end else if
}, 100);

```

Elastic function =

```auto
function Elastic(_mc, _prop, _end, _spring, _damp, _veloc)
{
    _mc._veloc = _veloc;
    _mc._end = _end;
    _mc._spring = _spring;
    _mc._damp = _damp;
    _mc[_prop] = Math.round(_mc[_prop]);
    _mc.finished = false;
    _mc.onEnterFrame = function ()
    {
        this._ax = (this._end - this[_prop]) * this._spring;
        this._veloc = this._veloc + this._ax;
        this._veloc = this._veloc * this._damp;
        this[_prop] = this[_prop] + this._veloc;
        epsilon = _prop != "_alpha" ? (5.000000E-002) : (4.000000E-001);
        if (Math.abs(this._veloc) < epsilon)
        {
            this[_prop] = _end;
            delete this.onEnterFrame;
            _mc.finished = true;
            _mc.onComplete(_prop);
        } // end if
    };
} // End of the function

```
