Checking if a click occurred outside a DisplayObject


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var coords:Point = this.localToGlobal(new Point(this.x, this.y));
  2. trace(stage.mouseX);
  3.  
  4. if (stage.mouseX < coords.x || stage.mouseX > coords.x + this.width || stage.mouseY < coords.y || stage.mouseY > coords.y + this.height)
  5. {
  6. trace(this, "click outside!!!");
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.