0

I am using starling framework and i have this code:

 tile1.addEventListener(TouchEvent.TOUCH, onTouch);

 private function onTouch(te:TouchEvent):void
        {

            if (te.getTouch(this, TouchPhase.HOVER))
                {
                        tile1.alpha = 1;
                }
            else
                {
                        tile1.alpha = 0;
                }

            if (te.getTouch(this, TouchPhase.ENDED))
                {
                    tile1.removeChildren();
                        tile1.addChild(arena);
                        tile1.alpha = 1;
                        tile1.removeEventListeners();

                }
        }

And i want to add the same event to other tiles but i want to say inside the event something like if object that is being clicked is tile1 than do something.

I want to do something like

tile1.addEventListener(TouchEvent.TOUCH, onTouch, "tile1"); tile2.addEventListener(TouchEvent.TOUCH, onTouch, "tile2");

An then in only one function i may know which object is being clicket.

I tried using te.Target but find no use...

Any help?

user3120770
  • 199
  • 1
  • 7
  • 19
  • What object is returned when you check te.target? If it's not giving you what you want (like parents or children of the tile) then maybe try changing the .touchable property to false of the objects you aren't interested in? – Scott Feb 01 '14 at 09:14

1 Answers1

0

Is this something that could help you? https://stackoverflow.com/a/13488640/1366887

I think he had the same question.

Some code form the post:

stage.addEventListener(MouseEvent.CLICK, onClick(true, 123, 4.56, "string"));
function onClick(b:Boolean, i:int, n:Number, s:String):Function {
  return function(e:MouseEvent):void {
    trace("Received " + b + ", " + i + ", " + n + " and " + s + ".");
  };
}
Community
  • 1
  • 1
Hunter Mitchell
  • 7,063
  • 18
  • 69
  • 116