19 Replies Latest reply on Jul 25, 2008 2:13 PM by Newsgroup_User

    Placing data from specific records into controls

    Developer504 Level 1
      I am working on a new screen with some Gauge controls. Each Gauge represents data from a specific record in an XML file, as follows:

      <data>
      <gauge label="CM" value="148.17" />
      <gauge label="DE" value="103.31" />
      <gauge label="EN" value="99.46" />
      </data>

      So, for example I want to put the value for CM into Gauge #1, DE into gauge #2 and etc.

      In more familiar programming languages I would either just loop through the records and assign the value for each one to a different variable (which I could then display in my Gauge), or better yet simply put the whole thing into an array and specify which record I wanted to display within each Gauge.

      I'm not sure how to do this in Flex. Do I drop it into an XMLListCollection? Is that more like an Array? How can I get the data from the right record into the right control?

      M.
        • 1. Placing data from specific records into controls
          Developer504 Level 1
          I was thinking maybe, I start with an XMLListCollection like this:

          <mx:XMLListCollection id="xmlListCollGP"
          source="{gpDs}">
          <mx:sort>
          <mx:Sort>
          <mx:fields>
          <mx:SortField id="sortFieldGP"
          name="@label"
          caseInsensitive="true"
          />
          </mx:fields>
          </mx:Sort>
          </mx:sort>
          </mx:XMLListCollection>

          ...sorting on the label which will allow me to pick the specific record I want. How can I take this then and get the specific value I want to put into my Gauge? Can I loop through it (if so, how) or is there some kind of way I can use it like an array in my Gauge?

          I need something to put into:

          value="500"

          like either value="{ceVal}" or value="{xmlListCollGP.sort="CE"}" or something similar....
          • 2. Placing data from specific records into controls
            Developer504 Level 1
            I just tried to put this loop into my WS event handler:

            private function handleXmlDataGP
            (event:ResultEvent):void
            {gpDs=XMLList(event.result.gauge);
            while (gpDs.@label = "CM")
            {cmValGP=(gpDs.@value)}
            }

            ...to try to assign it to a numeric variable gpDs. It compiles but gives me an error:

            "TypeError: Error #1089: Assignment to lists with more than one item is not supported."

            What does tht mean?
            • 3. Re: Placing data from specific records into controls
              Developer504 Level 1
              I tried this:

              for ("CM" in gpDs.label)
              {cmValGP=(gpDs.@value);}

              ...but it gave me an error:

              1050 Cannot assign to non-reference value
              • 4. Re: Placing data from specific records into controls
                Developer504 Level 1
                Ok I tried this:

                for (var i:String in gpDs)
                {
                if(i =="CM") {cmValGP=gpDs.@value}}
                }

                ...which compiles and runs with no error but still gives me no value in my variable cmValGP
                • 5. Re: Placing data from specific records into controls
                  Level 7

                  "Developer504" <webforumsuser@macromedia.com> wrote in message
                  news:g6cr10$gd4$1@forums.macromedia.com...
                  >I am working on a new screen with some Gauge controls. Each Gauge
                  >represents
                  > data from a specific record in an XML file, as follows:
                  >
                  > <data>
                  > <gauge label="CM" value="148.17" />
                  > <gauge label="DE" value="103.31" />
                  > <gauge label="EN" value="99.46" />
                  > </data>
                  >
                  > So, for example I want to put the value for CM into Gauge #1, DE into
                  > gauge #2
                  > and etc.

                  You would assign your XML's children() "property" as the dataProvider to a
                  Repeater or List-Based component. Have you looked at the help at _ALL_?
                  This is abundantly documented.


                  • 6. Placing data from specific records into controls
                    Developer504 Level 1
                    Yes actually I have looked at Help _ALL_DAY_ I will go look up some of these terms you've mentioned and see if I can find a solution which will work.

                    I'm new to Flex, doing a lot of stuff is easy but dealing with data seems to be incredibly byzantine compared to other languages I'm more familiar with.



                    M.
                    • 7. Re: Placing data from specific records into controls
                      Developer504 Level 1
                      I found an explanation of repeater which seems nearly identical to a loop... I don't get the difference.

                      Can you explain a bit about the children property of an XMLList or XML variable?
                      • 8. Re: Placing data from specific records into controls
                        Developer504 Level 1
                        Can a repeater work within a script? From the examples I can find it seems to be just MXML, how can I put this into filtering my XMLList variable so I can get the value I need?
                        • 9. Re: Placing data from specific records into controls
                          Developer504 Level 1
                          [quote]You would assign your XML's children() "property" as the dataProvider to a
                          Repeater or List-Based component. Have you looked at the help at _ALL_?
                          This is abundantly documented.





                          Can you provide a link to one of these help files which specifically documents this?

                          • 10. Re: Placing data from specific records into controls
                            Level 7

                            "Developer504" <webforumsuser@macromedia.com> wrote in message
                            news:g6d7m5$k6$1@forums.macromedia.com...
                            > [quote]You would assign your XML's children() "property" as the
                            > dataProvider to
                            > a
                            > Repeater or List-Based component. Have you looked at the help at _ALL_?
                            > This is abundantly documented.
                            >
                            >
                            >

                            >
                            > Can you provide a link to one of these help files which specifically
                            > documents
                            > this?

                            Here's what you do:

                            1) Click Help>Help Contents
                            2) Click the blue Search Scope Link
                            3) Create new context "How To"
                            4) Check "Adobe Flex 3 Help", then open it by clicking the "+"
                            5) Uncheck "Adobe Flex 3 Language Reference"
                            6) Uncheck "Legal Notices"
                            7) Press OK
                            8) Select that as your help context/OK
                            9) Type in XML in the search box/OK

                            The one that looks most likely now in the first page of links is Binding
                            data into an XML model (about 10 down on my help context that is similar but
                            not identical to what I said above), but I am confident you'll find
                            something in the results that will help you.

                            :-)

                            HTH;

                            Amy


                            • 11. Re: Placing data from specific records into controls
                              Level 7

                              "Developer504" <webforumsuser@macromedia.com> wrote in message
                              news:g6d7dq$9e$1@forums.macromedia.com...
                              > Can a repeater work within a script? From the examples I can find it
                              > seems to be just MXML, how can I put this into filtering my XMLList
                              > variable so I can get the value I need?

                              You can filter an XMLListCollection by using a FilterFunction, but you said
                              you just needed to map each data item in your XML to a component, which is
                              what a Repeater does.

                              HTH;

                              Amy


                              • 12. Placing data from specific records into controls
                                Developer504 Level 1
                                quote:

                                Here's what you do:
                                (snip)
                                I am confident you'll find
                                something in the results that will help you.


                                Thanks, I know how to look at the help files. But thanks for the vote of confidence.

                                I'm sure it's frustrating to read posts steeped in such unfamiliarity with basic Flex concepts, but I can assure you it's equally frustrating to recieve flippant answers to serious questions.

                                I'm a programmer with a background in a very different type of programming language so the entire paradigm of Flex is unfamiliar to me, as is the amazing complexity required to do simple things like pick a record out of some data. Nevertheless I currently have two Flex Apps deployed at major clients and running every day.

                                I'm still weak on the terminology and paradigms of Flex / AS 3 though I'm learning. This makes searching the help files very hard since I don't know how to translate what I'm trying to do, or in many cases what I'm looking at. I have spent all day on this today reading help files and trying various examples, to no avail.

                                I have purchased 5 expensive Flex books which I have found to be largely useless. The most helpful things have been Adobes online documentation, the blogs which provide examples, and a few very helpful people on this forum, who made an effort to meet me half-way and understand my gibberish.

                                Your posts, with all due respect, seem to have the purpose of mocking me for my ignorance of basic Flex concepts and terminology. Thanks, I already knew that. I am going to attend a training class on Flex as soon as possible, in the meantime I'm forced to try to get my project complete in spite of my own ignorance.

                                I'm also active on other forums related to software with which I am more familiar, and I try to actually help people, even the worst NOOBS.

                                M.
                                • 13. Re: Placing data from specific records into controls
                                  VarioPegged Level 2
                                  Those of us who try and help I think truly want to help, but it's incredibly frustrating to follow your posts and in the process try to help you.

                                  Here's my advice to you: start a thread with lucid explanations of the problems you're having ALONG with complete examples. Please don't continue to post to that thread with your findings as you're working something out. Post an answer when you have one. In the meantime we'll try and provide and answer.

                                  TS
                                  • 14. Re: Placing data from specific records into controls
                                    Developer504 Level 1
                                    Ok I'll follow your advice from here on in vario, you have been very helpful to me in the past and I appreciate it..
                                    • 16. Re: Placing data from specific records into controls
                                      Developer504 Level 1
                                      Thanks this was answered in another thread, but this helps me understand how to use loops in this way.

                                      M.
                                      • 17. Re: Placing data from specific records into controls
                                        VarioPegged Level 2
                                        You're welcome, but argghhhh, stop with the multiple threads on the same problem posting please!! I'm taking the time to help only to find that you've got other open posts with the same issue.

                                        TS
                                        • 18. Re: Placing data from specific records into controls
                                          Level 7

                                          "VarioPegged" <webforumsuser@macromedia.com> wrote in message
                                          news:g6dfek$8oj$1@forums.macromedia.com...
                                          > You're welcome, but argghhhh, stop with the multiple threads on the same
                                          > problem posting please!! I'm taking the time to help only to find that
                                          > you've got other open posts with the same issue.
                                          >
                                          > TS

                                          :-)


                                          • 19. Placing data from specific records into controls
                                            Developer504 Level 1
                                            I apologize again. I had started over on the thread on the theory that I'd done a poor job of explaining my problem initially.

                                            I kind of panicked today due to not expecting this to be a problem. Once I'd figured out how to get my gauge control working within my App over the last few days, and how to set values to it, I'd figured I'd dealt with the tough part. I was blindsided by the difficulty I encountered because in my last several projects I have been able to routinely import XML data and bind it to various controls.

                                            I thought if I did hit any minor issues with this part of the project i could solve them quickly. If you notice I haven't been posting nearly as many questions here because I'd learned enough finally to be able to find answers in the online Adobe examples and by reading the various Blogs.

                                            So I figured I had this nailed and would wrap it up this morning. Eight hours later I found out how wrong i was, thanks to you and Tracy I have it working now. As a result of the delay I am somewhat in dutch with my boss, probably grew a few gray hairs, but I have learned a lot.

                                            I will strictly follow all of your advice when posting to this forum in the future.

                                            M.