# Can this code be sped up?

**URL:** <https://forum.kirupa.com/t/can-this-code-be-sped-up/165460>\
**Category:** flash\
**Created:** [October 11, 2005, 9:35am UTC](https://forum.kirupa.com/t/can-this-code-be-sped-up/165460 "2005-10-11T09:35:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![overcast](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/overcast/32/1822_2.png) [@overcast](https://forum.kirupa.com/u/overcast)\
**Post date:** [October 11, 2005, 9:35am UTC](https://forum.kirupa.com/t/can-this-code-be-sped-up/165460/1 "2005-10-11T09:35:27Z")

</div>

In a website I’m designing I use this code to move from page to page, but on slower computers it tends to take ages & cause lots of strain on the processor. I’m Actionscript genius so please could the answer be spelled (or typed…) out - I’ve heard, but not sure if it’s true, that there is a more efficient way than onEnterFrame, please correct me if I’m wrong. Is there an alternative to this? I would really appreciate any and all help.

```auto
_global.targetX = 0;
_global.targetY = 0;
initWindow();
window_mc.container_mc.onEnterFrame = moveCamera;
function initWindow() {
        var c = 0;
        for (i=1; i<11; i++) {
                myClip = _root.window_mc.container_mc["clip"+i];
                if (i%2>0) {
                        myClip._x = 0;
                        myClip._y = c*552;
                        c++;
                } else {
                        myClip._x = 900;
                        myClip._y = _root.window_mc.container_mc["clip"+(i-1)]._y;
                }
        }
}
function moveCamera() {
        friction = 0.1;
        distanceX = (targetX-this._x)*friction;
        distanceY = (targetY-this._y)*friction;
        this._x += distanceX;
        this._y += distanceY;
}
function updateTargets(x, y) {
        targetX = x;
        targetY = y;
}

```

Cheers in advance,

Z
