Author Topic: Best design to handle button events in a parent script  (Read 3388 times)

DuaneDog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
Best design to handle button events in a parent script
« on: March 02, 2014, 04:36:02 AM »
I have a simple first, next, back, last navigation panel. So four buttons inside a panel. What is the best way to trap the click events in the parent script? Or do I need to make a script for each individual button?  I know this is probably very simple but I'm having a hard time tracking down specific documentation on the best practice.

DuaneDog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: Best design to handle button events in a parent script
« Reply #1 on: March 02, 2014, 05:43:15 AM »
I ended up using the legacy message event script to handle this.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Best design to handle button events in a parent script
« Reply #2 on: March 02, 2014, 08:15:14 AM »
I'd have a controller script on the panel (or where you instantiate the buttons) and add a listener with UIEventListener.

http://pastebin.com/S42AN9ma (since the code tags are messing with me)