0

Introduction of my code: I have a Vgroup inside a scroller, because the user is going to add a numbers of objects.

Each time the user clicks the Button, its going to add to the Vgroup and Hgroup that has 3 objects inside (look in agregar_clickhandler). This 3 objects are a textInput, and numeric stepper and a delete icon.

What I want to do is to extract the information in the textinput and numeric stepper inside each Hgroup each time the user edits it.

For example, when I have to delete an Hgroup, i use the Eliminar function, which works well. I try to do something similar to obtain the text in the textInput but nothing is working.

What I am doing is I add an event listener to the TextInput, so when the user types something, I can extract that information.

I appreciate the help.

<s:Button id="agregar" x="36" y="533" label="Agregar mas mensajes " fontSize="20"
  click="agregar_clickHandler(event)"/>

<s:Scroller x="36" y="99" width="554" height="400">
    <s:VGroup width="100%" height="100%" id="scroller">
    </s:VGroup>
</s:Scroller>

        protected function agregar_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub
            var group:HGroup = new HGroup();
            group.width = 552; 
            group.height = 65; 

            var input:TextInput = new TextInput(); 
            input.width = 360;
            input.height = 49; 
            input.addEventListener(TextOperationEvent.CHANGE, actualizar);

            var num:NumericStepper = new NumericStepper();
            num.width = 107;
            num.height = 49;
            num.maximum = 100; 

            var del:Button = new Button(); 
            del.width = 70; 
            del.height = 49; 
            del.label = "delete";
            del.setStyle("icon", deleteicon); 
            del.addEventListener(MouseEvent.CLICK, eliminar);  

            group.addElement(input);
            group.addElement(num); 
            group.addElement(del); 

            scroller.addElement(group); 
        }

protected function eliminar(event:MouseEvent):void
        {
            scroller.removeElement(HGroup(Button(event.currentTarget).parent));
        }

protected function actualizar(event:TextOperationEvent):void
        {

           var obj:Object = scroller.getElementIndex(HGroup(TextInput(event.currentTarget).parent));

        }
Alessandroempire
  • 1,640
  • 4
  • 31
  • 54
  • You should use a DataGroup or a List component to add and remove views dynamically through ItemRenderers. Have a look a this answer to a pretty similar question: http://stackoverflow.com/questions/14870771/how-to-select-an-object-in-a-flex-hgroup/14911747 – RIAstar Apr 06 '13 at 20:16

1 Answers1

0

Try this:

protected function actualizar(event:TextOperationEvent):void
{
    var currentHGroup:HGroup = HGroup(TextInput(event.currentTarget).parent);

    var currentText:String = (currentHGroup.getElementAt(0) as TextInput).text;
    var currentNumber:int = (currentHGroup.getElementAt(1) as NumericStepper).value;
}
Anton
  • 4,544
  • 2
  • 25
  • 31