1

i am currently building a pond flash application, and it has a water ripple effect , when it is rendered, the water ripple effect is not at my mouse position when in fact my function makes it draws on my mouse position. i did a show redraw region on the flash player and attached is the picture.does anyone know how to solve this problem? enter image description here

addEventListener(MouseEvent.MOUSE_MOVE,onMouseMoveTriggered);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownTriggered);
private function onMouseMoveTriggered(e:Event):void {
            if (canPlay)
            {
            waterMovementSound.play();
            canPlay = false;
            soundTimer.start();
            }
            myRippler.drawRipple(stage.mouseX, stage.mouseY, 10, 0.9);

            //evt.stageX
            //evt.stageY
        }
        private function onMouseDownTriggered(e:Event):void {
            myRippler.drawRipple(stage.mouseX,stage.mouseY, 10, 0.9);
            stage.mouseX;
            stage.mouseY;


        }
sutoL
  • 1,737
  • 10
  • 27
  • 48

2 Answers2

2

I would think you need to check that the stage.align is set to topLeft and stage.scaleMode is set to noScale, unless you actually need to have differing setup.

If you've still got issues then this could possibly be because you're drawing inside a nested container (Sprite,DisplayObject,etc) and that is offset. If that's the case you could use globalToLocal to solve the issue of positional problems concerning mouse?

simonrichardson
  • 1,049
  • 8
  • 14
  • my hierarchy goes like this, waterMain(document class)-->has a child of background extending Sprite, and the rippler is drawn on the bg.and the same document class also has childs of "Fishes" objects swimming . – sutoL Jul 13 '11 at 01:14
  • the thing is if i dont add any fish objects into it the efffects are fine. when i add them the water ripple starts to go haywire. – sutoL Jul 13 '11 at 01:16
0

I found a work around to this problem, the effects only move out of place when my fishes are swimming towards a random x,y point near to the canvas max Y and max X, so i reduced the generated random XY values for the fishes to swim to by much lesser than max Y and max X, therefore it wont swim close to the edges.

sutoL
  • 1,737
  • 10
  • 27
  • 48