0 Replies - 1030 Views - Last Post: 14 May 2012 - 03:15 AM

#1 mano_gold  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-May 12

if ... else mouse follow help.

Posted 14 May 2012 - 03:15 AM

Hi, I'm using this code for a movie to follow mouse and nest when it leaves the stage. The movie is a hand and I need it to be a left hand on the left of the stage then nest while the right hand becomes active on the other side. Any help would be gratefully appreciated.

var targetX:Number;
var targetY:Number;

var sp:Sprite = new Sprite();
with(sp.graphics){
beginFill(0x000000);
drawRect(0,0,stage.stageWidth,stage.stageHeight);
endFill();
}
addChild(sp);
sp.alpha = 0;
sp.addEventListener(MouseEvent.MOUSE_MOVE,updateTargetF)

stage.addEventListener(Event.MOUSE_LEAVE,nestF);
function updateTargetF(e:MouseEvent) {
targetX=mouseX;
targetY=mouseY;
trace(targetX);
}

function nestF(e:Event) {
targetX=150;
targetY=700;
}

stage.addEventListener(Event.ENTER_FRAME,followBall);

function followBall(event:Event):void {
var dx:int = hand_mc.x - targetX;
var dy:int = hand_mc.y - targetY;
hand_mc.x -= dx / 5;
hand_mc.y -= dy /5;
}

Is This A Good Question/Topic? 0
  • +

Page 1 of 1