5 Replies Latest reply on Nov 20, 2008 8:37 PM by Newsgroup_User

    Funky Repeater Problem (Please help !!!)

    Gregory Lafrance Level 6
      In my attached code, if you edit one item of the first VBox first TextArea, after typing the first character you can't type anymore.

      If you edit one item of the second VBox first TextArea, after leaving that TextArea you can't change anymore of the TextAreas in VBox 2.
        • 1. Re: Funky Repeater Problem (Please help !!!)
          Level 7

          "Greg Lafrance" <webforumsuser@macromedia.com> wrote in message
          news:gg28mt$a2l$1@forums.macromedia.com...
          > In my attached code, if you edit one item of the first VBox first
          > TextArea,
          > after typing the first character you can't type anymore.
          >

          It seems like what's happening is that you get into a feedback loop where
          you change an item in the ac and it causes the whole repeater to render
          again. I got it closer with this, but it's still a bit screwy in the focus
          dept.

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"

          backgroundGradientColors="[0xffffff, 0xffffff]"

          horizontalAlign="left">

          <mx:Script>

          <![CDATA[

          import mx.collections.ArrayCollection;

          import mx.controls.*;


          [Bindable] private var ac1:ArrayCollection = new ArrayCollection([

          "This is the first string in the application ArrayCollection.",

          "This is the second string in the application ArrayCollection.",

          "This is the third string in the application ArrayCollection.",

          "This is the fourth string in the application ArrayCollection."

          ]);


          [Bindable] private var ac2:ArrayCollection = new ArrayCollection([

          "This is the first string in the application ArrayCollection.",

          "This is the second string in the application ArrayCollection.",

          "This is the third string in the application ArrayCollection.",

          "This is the fourth string in the application ArrayCollection."

          ]);


          private function myChangeHandler(event:Event):void{

          /* deliberately make an error, since the Flex team

          used that brilliant mechanism as the only way to

          determine the repeater is done executing. */

          try {

          var makeError:Object = rp1.currentItem;

          } catch (error:Error) {

          //the repeater has executed, so we now want to

          ac1.setItemAt(entryText1[event.currentTarget.instanceIndices].text,

          event.currentTarget.instanceIndices);

          return;

          } finally {

          //do nothing. we wanted an error

          }


          }


          private function myFocusOutHandler(event:FocusEvent):void{

          ac2.setItemAt(entryText2[event.currentTarget.instanceIndices].text,

          event.currentTarget.instanceIndices);

          }

          ]]>

          </mx:Script>

          <mx:Label text="Change Event"/>

          <mx:VBox width="100%" height="100%">

          <mx:Repeater id="rp1" dataProvider="{ac1}">

          <mx:TextArea id="entryText1" text="{rp1.currentItem}" editable="true"

          width="100%" height="20" valueCommit="myChangeHandler(event);"

          borderThickness="0" selectable="true"/>

          </mx:Repeater>

          </mx:VBox>

          <mx:Label text="Focus Event"/>

          <mx:VBox width="100%" height="100%">

          <mx:Repeater id="rp2" dataProvider="{ac2}">

          <mx:TextArea id="entryText2" text="{rp2.currentItem}" editable="true"

          width="100%" height="20" focusOut="myFocusOutHandler(event);"

          borderThickness="0" selectable="true"/>

          </mx:Repeater>

          </mx:VBox>

          </mx:Application>


          • 2. Re: Funky Repeater Problem (Please help !!!)
            Gregory Lafrance Level 6
            Thanks for the suggestion. I think I may use some other component for what I am trying to do. This funky focus issue is fairly irritating.

            As for what I am trying to do, I'm building a file list in the application, where the list is a bunch of paths to files, such as Windows .rc files.

            The paths are stored in an ArrayCollection, but I need to present them to the user so they have the opportunity to edit the paths if necessary.

            I would have preferred putting them all in one TextArea, but I didn't know how to use myTextArea.text += ac.getItemAt(myIndex); and be able to add a newline so each AC entry is on the next line in the TextArea.

            Then after the user updates the text in the TextArea, I would just write out whatever remains in the TextArea.text to file, but once again, the newlines must be retained in the file I write to.

            In this scenario there is no updating of the AC, but I need those newlines to take effect within the TextArea and in the written file.

            Thanks again for your help Amy!
            • 3. Re: Funky Repeater Problem (Please help !!!)
              Level 7

              "Greg Lafrance" <webforumsuser@macromedia.com> wrote in message
              news:gg2sdq$34p$1@forums.macromedia.com...
              > Thanks for the suggestion. I think I may use some other component for what
              > I am
              > trying to do. This funky focus issue is fairly irritating.
              >
              > As for what I am trying to do, I'm building a file list in the
              > application,
              > where the list is a bunch of paths to files, such as Windows .rc files.
              >
              > The paths are stored in an ArrayCollection, but I need to present them to
              > the
              > user so they have the opportunity to edit the paths if necessary.
              >
              > I would have preferred putting them all in one TextArea, but I didn't know
              > how
              > to use myTextArea.text += ac.getItemAt(myIndex); and be able to add a
              > newline
              > so each AC entry is on the next line in the TextArea.
              >
              > Then after the user updates the text in the TextArea, I would just write
              > out
              > whatever remains in the TextArea.text to file, but once again, the
              > newlines
              > must be retained in the file I write to.
              >
              > In this scenario there is no updating of the AC, but I need those newlines
              > to
              > take effect within the TextArea and in the written file.
              >
              > Thanks again for your help Amy!

              Why not just use a List? If you use itemIsEditor, I think that it will
              update your AC for you.


              • 4. Re: Funky Repeater Problem (Please help !!!)
                Gregory Lafrance Level 6
                I ended up just using a TextArea and writing the file from there. That way the user can easily delete entire blocks of lines. Line endings render fine.

                Thanks for your help Amy!
                • 5. Re: Funky Repeater Problem (Please help !!!)
                  Level 7

                  "Greg Lafrance" <webforumsuser@macromedia.com> wrote in message
                  news:gg5dqk$d4h$1@forums.macromedia.com...
                  >I ended up just using a TextArea and writing the file from there. That way
                  >the user can easily delete entire blocks of lines. Line endings render
                  >fine.
                  >
                  > Thanks for your help Amy!

                  Not sure how helpful I was, but you're welcome ;-)