2013-04-02 3 views
0

내 코드 소개 : 사용자가 많은 수의 객체를 추가하기 때문에 스크롤러 안에 Vgroup이 있습니다.Flex에서 Hgroup의 첫 번째 객체 가져 오기

사용자가 Button을 클릭 할 때마다 Vgroup에 추가되고 Hgroup 내에 3 개의 객체가 포함됩니다 (agregar_clickhandler 참조). 이 3 개의 객체는 textInput 및 숫자 스테퍼 및 삭제 아이콘입니다.

내가 원하는 것은 사용자가 편집 할 때마다 각 Hgroup 내부의 textinput 및 numeric stepper에서 정보를 추출하는 것입니다.

예를 들어, Hgroup을 삭제해야 할 때 Eliminar 함수를 사용하면 효과적입니다. textInput에서 텍스트를 얻기 위해 비슷한 작업을 시도하지만 아무것도 작동하지 않습니다.

내가하고있는 일은 이벤트 리스너를 TextInput에 추가하기 때문에 사용자가 무언가를 입력 할 때 그 정보를 추출 할 수 있습니다.

감사합니다.

<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)); 

     } 
+0

당신은 추가 ItemRenderers을 통해 동적 뷰를 제거하기 위해 DATAGROUP 또는 List 구성 요소를 사용해야합니다. 꽤 비슷한 질문에 대한 답변을보십시오 : http://stackoverflow.com/questions/14870771/how-to-select-an-object-in-a-flex-hgroup/14911747 – RIAstar

답변

0

이 시도 :

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; 
}