Author Topic: Add Event Listener to a FlxSprite  (Read 11516 times)

felipe

  • Member
  • **
  • Posts: 36
  • Karma: +0/-0
  • games!
    • View Profile
    • i love pixel
Add Event Listener to a FlxSprite
« on: Fri, Jun 17, 2011 »
Does anyone know how can I do this, I've tried this.addEventListener in the same sprite class, but it gives me error, also used FlxG.stage.addEventListener, but i want to do it like _player.addEventListener  _player being a FlxSprite.
Thanks

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Add Event Listener to a FlxSprite
« Reply #1 on: Fri, Jun 17, 2011 »
You can't, FlxSprites aren't display objects in the traditional Flash sense, so they don't dispatch or listen for any kind of event.

What is it you're trying to do?
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

felipe

  • Member
  • **
  • Posts: 36
  • Karma: +0/-0
  • games!
    • View Profile
    • i love pixel
Re: Add Event Listener to a FlxSprite
« Reply #2 on: Fri, Jun 17, 2011 »
I want to click over the sprite and execute a function.

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Add Event Listener to a FlxSprite
« Reply #3 on: Fri, Jun 17, 2011 »
No then. FlxSprites have a method called pixelsOverlapPoint() which can be fed the mouse x/y coordinates, and use that in conjunction with checking for a mouse click.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius