Skip to content

Instantly share code, notes, and snippets.

@alamboley
Last active October 12, 2015 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alamboley/4022051 to your computer and use it in GitHub Desktop.
Save alamboley/4022051 to your computer and use it in GitHub Desktop.
How to handle mouse events (Citrus Engine recipe)
var coin:Coin = new Coin("coin", {view:"art.png", touchable:true});
//Within your state class. Same process for Starling or Away3D
var coinArt:DisplayObject = view.getArt(coin) as DisplayObject;
coinArt.addEventListener(MouseEvent.CLICK, handleCoinClick);
private function handleCoinClick(e:MouseEvent):void
{
var clickedCoin:Coin = view.getObjectFromArt(e.currentTarget) as Coin;
if (clickedCoin)
{
//do your logic here
clickedCoin.kill = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment