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.
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!?