eddjc
03-02-2010, 09:51 AM
Hey All,
Scratching my head over this - I have a script that displays a list of horizontally, and when the mouse moves across the applet, the icons move in the opposite direction to the mouse i.e.:
------------------------------------ <- Frame
|icon icon icon icon icon icon ic|on icon icon icon icon
------------------------------------
^visible portion of flash app
when mouse is halfway, the icons are at x= 1/2 * (iconsLength - frame length)
The icons are contained in a Canvas Element which includes the following eventHandler:
private function onMouseMove(event:MouseEvent):void {
var mouseX:Number = event.localX;
var frameWidth:Number = stage.width;
var length:Number = width;
var offSet:Number = mouseX/length * (length - frameWidth);
x = - offSet;
//trace("mouseX: " + mouseX + " frameWidth: " + frameWidth + " length: " + length + " offSet: " + offSet);
//trace("" + mouseX + "/" + frameWidth + " * (" + length + " - " + frameWidth + ") = " + offSet);
}
and in override protected function createChildren():void:
addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
Everything works fine, except that when the cursor moves over one of the icons, the movement jerks - I do have a couple of MouseEvent handlers in the icons (MouseOver and MouseOut) but even with these removed it still happens.
Any ideas where it's going wrong? I thought perhaps running over the icons would override the MOUSE_MOVE event of the frame...
Many thanks
Edd
Scratching my head over this - I have a script that displays a list of horizontally, and when the mouse moves across the applet, the icons move in the opposite direction to the mouse i.e.:
------------------------------------ <- Frame
|icon icon icon icon icon icon ic|on icon icon icon icon
------------------------------------
^visible portion of flash app
when mouse is halfway, the icons are at x= 1/2 * (iconsLength - frame length)
The icons are contained in a Canvas Element which includes the following eventHandler:
private function onMouseMove(event:MouseEvent):void {
var mouseX:Number = event.localX;
var frameWidth:Number = stage.width;
var length:Number = width;
var offSet:Number = mouseX/length * (length - frameWidth);
x = - offSet;
//trace("mouseX: " + mouseX + " frameWidth: " + frameWidth + " length: " + length + " offSet: " + offSet);
//trace("" + mouseX + "/" + frameWidth + " * (" + length + " - " + frameWidth + ") = " + offSet);
}
and in override protected function createChildren():void:
addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
Everything works fine, except that when the cursor moves over one of the icons, the movement jerks - I do have a couple of MouseEvent handlers in the icons (MouseOver and MouseOut) but even with these removed it still happens.
Any ideas where it's going wrong? I thought perhaps running over the icons would override the MOUSE_MOVE event of the frame...
Many thanks
Edd