Number of the object clicked

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default Number of the object clicked

    Hello,
    i have this code.

    How can i get the number of the button clicked?
    i have to assign a number, when an user click on the button i have to get this
    number to do my job..



    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

    <mx:Script>
    <![CDATA[
    import mx.events.FlexEvent;
    import mx.controls.Button;
    import mx.controls.Image;
    import mx.containers.HBox;

    private function init():void{

    for(var i:int; i<6; i++){
    var con:HBox = new HBox();
    var icon:Image = new Image();
    var bt1:Button = new Button()
    var bt2:Button = new Button();
    bt1.label=String(i);
    bt2.label="X";

    con.addChild(icon);
    con.addChild(bt1);
    con.addChild(bt2);
    usersList.addChild(con);
    }
    }

    private function click(event:Event):void{
    trace(event.toString());
    trace(event.target.toString());
    trace(event.currentTarget.toString());
    }

    ]]>
    </mx:Script>


    <mx:VBox id="usersList" creationComplete="init();" />


    </mx:Application>

    dam85 Guest

  2. Similar Questions and Discussions

    1. Which chart was clicked on?
      Hi, event.target.name appears to give me what I'm after but is there a better (more usual) way of obtaining the id/name of the chart that was...
    2. Which cell was clicked
      I would like to create a postBack when user click on the cell: In my dataGrid, I put the button column: <asp:buttoncolumn visible="false"...
    3. sort from the smallest number to the highest number
      Hi Just say I want to sort the row by using the fifth column data as reference from the smallest the largest number, if using sort, It will give...
    4. Is there a way to + number in a shared object?
      If you have a textfield like a scoreboard with the number 10 you can use: btn1.onPress = function() { _root.scoreboard += 5; }; to add 10...
    5. I need help on Array object, (summing number elements)
      i.e : myArray = newArray() myArray = ; sum = Number(myArray+myArray+myArray); trace (sum) //traces 15
  3. #2

    Default Re: Number of the object clicked

    i have to get the number of the "row" i mean row the number of the HBox inside the VBox
    dam85 Guest

  4. #3

    Default Re: Number of the object clicked

    Hey, what you can do is following,

    add an EventListener to the HBox

    con.addEventListener(MouseEvent.CLICK,click,false, 0,true);

    give your HBox an id

    con.id = "MyHBox" + i;

    and in the eventHandler you have access to the HBox with
    event.currentTarget

    dietmar.paulus Guest

  5. #4

    Default Re: Number of the object clicked

    this is the code and the output
    dam85 Guest

  6. #5

    Default Re: Number of the object clicked

    write

    private function click(event:Event):void{
    trace(HBox(event.currentTarget).id );
    }

    then you trace your ID, what you have to do now is to "parse" your output so that you get the row
    dietmar.paulus Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139