# Moving Sprites on the x-axis

**URL:** https://forum.kirupa.com/t/moving-sprites-on-the-x-axis/288644
**Category:** flash
**Created:** [May 19, 2009, 10:34am UTC](https://forum.kirupa.com/t/moving-sprites-on-the-x-axis/288644 "2009-05-19T10:34:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)
#### Post date: [May 19, 2009, 10:34am UTC](https://forum.kirupa.com/t/moving-sprites-on-the-x-axis/288644/1 "2009-05-19T10:34:00Z")

</div>

Hi I am converting at last to as3 …

for ease, I am using tweener to move the objects.  
I have randomly generated a load of Sprites, inside a container, along the (x,y,z) axis.

I want to scroll the objects along the x-axis when I move the mouse left and right.

```auto
function Scroll():void
        {
            cont = new Sprite();
            cont.x = stage.stageWidth * 0.5;
            cont.y = stage.stageHeight * 0.5;
            addChild(cont);
            makeChildren();
            addEventListener(MouseEvent.MOUSE_MOVE, onMove); // this is what worries me! - the placing of this line of code
        }
function makeChildren():void
for(var i:uint = 100; i>0; i--)
            {
                var sp:Sprite = new Sprite();               
                sp.graphics.beginFill(Math.random()*0xFFFFFF);
                sp.graphics.drawRect(0,0,300,300);
                sp.x = Math.random()*1000-500;
                sp.y = Math.random()*1000-500;
                sp.z = i*200;
                cont.addChild(sp);
}
 onMove(e:MouseEvent):void
        {
            var sp:Sprite = Sprite(e.target);
            Tweener.addTween(cont,{x:mouseX,time:1}); // simply moving the objects to mouseX
        }

```

Great - Hmm - but the objs only move when the mouse rolls Over them. Why is this? I want them to move whenever the mouse does …

Can anyone help!?
