Announcement

Collapse
No announcement yet.

Buttons sharing the same event listener?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Buttons sharing the same event listener?

    Hello, Since im working in an skilltree for my game i decided to do a simple custo scaleform class , since every skill is in fact just a UILoader with no text i made a copy of the button class and widget, and changed it to how i liked

    Now, this works i can set the icon of every skill trough an array but since the icons are clickeable and they all do the same action(Set theyr current icon to another UILoader once clicked)

    So at first i tried using a single eventListener and added it to all my buttons like this

    Code:
    		case ('ISlot0'): // islot = GFxClikWidget array
    	    ISlot[0] = GFxClikWidget(Widget);
    		ISlot[0].AddEventListener('CLIK_click',SlotPress);
    		break;
    		
    		case ('ISlot1'): 
    	    ISlot[1] = GFxClikWidget(Widget);
    		ISlot[1].AddEventListener('CLIK_click',SlotPress);
    		break;

    Now the function thet gets called

    Code:
    function SlotPress(GFxClikWidget.EventData ev)
    {
    local int index;
    local string iconPath;
    index = ev.index;
    ISlot[i].GetString("icon"); // alredy changed the class to allow me to do this
    skillPreview.SetString("source",iconPath); // and now just set the icon
    }
    But my issue is that every time the widget is clicked the index is always 0, it never changes so this is exactly where i am stuck, since i cant find a way to get the current selected button/skill

    Unless i manually add a diferent event listener for every skill but i really want to avoid that

    Any help as usual is appreciated

    #2
    First of all, it looks like you are creating the var index, but instead using ISlot[i] - shouldn't you be using ISlot[index]?

    Second, are you using AS3 or AS2? If AS3, try instead:

    Code:
    index = ev._this.GetObject("target").GetFloat("index");

    Comment


      #3
      Oh right i missed that one but still switching ISlot[i] to use index instead returns 0 in every button

      and im using AS2 right now since i couldnt get UILoaders to work in AS3

      for some reason if i do someting like

      Code:
      iconPath = ISlot[index].GetString("label"); //
      it returns "undefined" while doing

      Code:
      iconPath = ISlot[0].GetString("label");
      returns the slot 0 icon path

      Comment


        #4
        bump........

        Comment


          #5
          have you trace your ev.index? i think that its possible that your button didn't send the index data to the UnrealScript.

          you could try check out buttonGroup class. they maybe something similiar on what you are trying to achieved.

          Comment


            #6
            This really depending on alot of things. Including how your Flash content is setup. Perhaps if you could send me a simple example file with all the moving parts so to speak, I could help you debug this.

            Comment


              #7
              I got your example files. I will look at them this week, and hopefully have a solution for you.

              Comment


                #8
                Thanks matt

                Comment

                Working...
                X