12 Replies Latest reply on Feb 28, 2011 5:07 PM by Scarrfo

    populate datalist with xml

    number2sandwich

      I have made an interface in Flash Catalyst CS5 with a datalist component.

      The datalist component has a repeated item as is required.

       

      So I import that .fxp file into Flash Builder 4.

      I create a dataservice (xml) and bind that to to the datalist component using the Data Services wizard.

       

      When I run the app, I do not get the datalist populated with data.

       

      I have been trying to rsch this, but with all the different build changes, I can't seem to wade thru it.

       

      Help Cecil help.

        • 1. Re: populate datalist with xml
          SunilAdobe Adobe Employee

          Is there any error in the log?

           

          Thanks

          -Sunil

          • 2. Re: populate datalist with xml
            number2sandwich Level 1

            Is there a log file to check?

            I don't have network monitor - not premium version.

             

            The process itself is only partially documented and poorly at that.

            Big gaps and disconnected texts.

             

            I am trying to use a local xml file.

             

            Is there any clear instructions and how to proceed?

            Like once I import the fxp file I created in Flash Catalyst, with a datalist with a 'repeated item'.

            • 3. Re: populate datalist with xml
              somascope Level 3

              I'm a new person with Flash Builder, but one tutorial I found alks about loading XML data (local or from a server, the path to the file is the same).

              http://www.adobe.com/devnet/flex/videotraining/_jcr_content/bodycontent1/modal_9.content.h tml

               

              This is a 10-minute video clip that seemed pretty straight-forward. Maybe it can help you with this, though I don't know what kind of code Catalyst creates...

               

              Highlights of this talk about:

               

              Using a creationCompelte property of your main Application tag:

              <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                  ...

                  ...

                  creationComplete="myHttpService.send()">

               

              Creating your HTTPService in the Declarations tag:

                  <fx:Declarations>

                      <s:HTTPService

                             id="myHttpService"

                             url="/xml/yourXmlFile.xml"/>

                  </fx:Declarations>

               

              And then binding that data to the component that uses it. In this case, a dropDownList:

              ... dataProvider="{myHttpService.lastResult.employees.employee}"

              • 4. Re: populate datalist with xml
                number2sandwich Level 1

                Thanks for the reply.

                 

                The vid is for some incarnation of FB in 2009.

                I am using FB4, that ships with CS5 .. nonPremium edtn, so no network monitor feature.

                So everything is different again compared to the vid.

                 

                I am pasting in code below for the main.msxml file that is created in FB4 after importing .fxp file from Flash Catalyst CS5.

                There are 2 datalists I wish to populate with a LOCAL XML file.

                 

                I would like to use the "wizards" in FB4 to bind the data, but I have yet to find an article or video that is complete or 2 that agree with eachother.

                 

                This code before attempting to bind data, however the hell one does that successfully, if it is truly possible...

                 

                <?xml version='1.0' encoding='UTF-8'?>

                <s:Application xmlns:d="http://ns.adobe.com/fxg/2008/dt" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:graphics="assets.graphics.*" xmlns:fc="http://ns.adobe.com/flashcatalyst/2009" backgroundColor="#FFFFFF" height="846" preloaderChromeColor="#FFFFFF" width="1009">

                <fx:Script><![CDATA[

                protected function list_changeHandler():void

                {

                currentState='Page2';

                }

                ]]></fx:Script>

                <s:states>

                <s:State fc:color="0xcc0000" name="Page1"/>

                <s:State name="Page2"/>

                </s:states>

                <fx:DesignLayer id="designlayer2" d:userLabel="vidList" visible.Page1="false">

                <s:List id="list1" skinClass="components.categoryTitleDataList2" x="-304" x.Page2="64" y="300">

                <s:ArrayCollection>

                <fx:String>Video Link</fx:String>

                </s:ArrayCollection>

                </s:List>

                </fx:DesignLayer>

                <s:Group id="group1" d:userLabel="edge" x="55" y="289">

                <s:BitmapImage height="373" smooth="true" source="@Embed('/assets/images/mp3psd/Shape 2_s Outer Stroke.png')" d:userLabel="Shape 2's Outer Stroke" width="706" x="3" y="4"/>

                <s:BitmapImage smooth="true" source="@Embed('/assets/images/mp3psd/Shape 2.png')" d:userLabel="Shape 2" x="0" y="0"/>

                </s:Group>

                <s:Rect height="366" id="rect1" width="56" x="1" y="299">

                <s:fill>

                <s:SolidColor color="#FFFFFF"/>

                </s:fill>

                </s:Rect>

                <fx:DesignLayer d:userLabel="Player">

                <s:RichText color="#3A3A3A" fontFamily="Arial Bold" fontSize="14" height="17" kerning="off" lineHeight="100%" d:userLabel="description" whiteSpaceCollapse="preserve" width="88" x="431" y="550">

                <s:content><s:p><s:span>D</s:span><s:span kerning="auto">escription:</s:span></s:p><s:p><s:span fontFamily="Arial" kerning="auto"><![CDATA[ ]]></s:span></s:p></s:content>

                </s:RichText>

                <s:RichText color="#3A3A3A" fontFamily="Arial Bold" fontSize="14" lineHeight="100%" textAlign="center" d:userLabel="length" whiteSpaceCollapse="preserve" x="647" y="530">

                <s:content><s:p><s:span>Length:</s:span><s:span fontFamily="Arial"><![CDATA[ ]]></s:span></s:p></s:content>

                </s:RichText>

                <s:RichText color="#3A3A3A" fontFamily="Arial Bold" fontSize="14" lineHeight="100%" d:userLabel="date" whiteSpaceCollapse="preserve" x="429" y="530">

                <s:content><s:p><s:span>Date:</s:span><s:span fontFamily="Arial"><![CDATA[ ]]></s:span></s:p></s:content>

                </s:RichText>

                <s:RichText color="#3A3A3A" fontFamily="Arial Bold" fontSize="14" kerning="off" lineHeight="100%" textAlign="center" d:userLabel="title" whiteSpaceCollapse="preserve" x="430" y="508">

                <s:content><s:p><s:span>T</s:span><s:span kerning="auto">itle:</s:span><s:span fontFamily="Arial" kerning="auto"><![CDATA[ ]]></s:span></s:p></s:content>

                </s:RichText>

                <s:TextInput text="" d:userLabel="inputTitle" x="469" y="504"/>

                <s:TextInput height="22" text="" d:userLabel="inputLength" width="50" x="703" y="523"/>

                <s:TextInput height="97" text="" d:userLabel="inputDescr" width="325" x="433" y="566" focusColor.Page2="#0065FF"/>

                <s:TextInput text="" d:userLabel="inputDate" x="469" y="526"/>

                </fx:DesignLayer>

                <s:VideoPlayer autoPlay="false" color="#2B4381" height="192" id="videoplayer1" scaleMode="stretch" skinClass="spark.skins.spark.VideoPlayerSkin" source="assets/media/july2010_480x270.flv" width="331" x="429" y="301"/>

                <fx:DesignLayer id="designlayer1" d:userLabel="catList">

                <s:List change="list_changeHandler()" id="list2" includeIn="Page1" skinClass="components.categoryTitleDataList2" x="64" y="300">

                <s:ArrayCollection>

                <fx:String>Category Title</fx:String>

                </s:ArrayCollection>

                </s:List>

                </fx:DesignLayer>

                <s:transitions>

                <s:Transition autoReverse="true" fromState="Page1" toState="Page2">

                <s:Parallel>

                <s:Parallel target="{list1}">

                <s:Move autoCenterTransform="true" duration="150"/>

                </s:Parallel>

                <s:Parallel target="{list2}">

                <s:Fade duration="50"/>

                </s:Parallel>

                <s:Parallel target="{designlayer2}">

                <s:Fade duration="50"/>

                </s:Parallel>

                </s:Parallel>

                </s:Transition>

                <s:Transition fromState="Page2" toState="Page1" autoReverse="true">

                <s:Parallel>

                <s:Parallel target="{designlayer2}">

                <s:Fade duration="0"/>

                </s:Parallel>

                <s:Parallel target="{list1}">

                <s:Move duration="0" autoCenterTransform="true"/>

                </s:Parallel>

                <s:Parallel target="{list2}">

                <s:Fade duration="0"/>

                </s:Parallel>

                </s:Parallel>

                </s:Transition>

                </s:transitions>

                </s:Application>

                • 5. Re: populate datalist with xml
                  number2sandwich Level 1

                  Hello, anybody out there in Adobe-land??

                  • 7. Re: populate datalist with xml
                    Scarrfo Level 1

                    You are missing code.  If you can't figure it out and don't mind zipping the entire project up and posting it somewhere I can take a look at it later.

                     

                    Directory structure should look as follows.

                     

                    temp9850.jpg

                    • 8. Re: populate datalist with xml
                      number2sandwich Level 1

                      Yes, the above post was the code in main.mxml..

                       

                      I created an xml file to use for data. But in above I have not yeat taken any steps to 'bind to data' so as to keep a fresh starting point.

                      I tried over and over to do so(bind to data), but with not luck, so I re-imported fresh .fxp file created by FC5 into FB4.

                       

                      I have zipped entire project, but do not see a way to attach it here, - is there a place I can send it to you?

                       

                      Thanks!

                      • 9. Re: populate datalist with xml
                        Scarrfo Level 1

                        You can upload to mediafire.com  it's free and no registration.  It will provide a download link for you.

                         

                        Link here

                        • 10. Re: populate datalist with xml
                          number2sandwich Level 1

                          OK - I created an acct with mediafire (http://www.mediafire.com/?39dzkzfnycfiy)

                           

                          I uploaded the project zip, and the xml file wish to bind the datalist to, as a local xml file.

                           

                          cheers!

                          • 11. Re: populate datalist with xml
                            Scarrfo Level 1

                            Got it. I will check it out in an a few hours from this post.

                            • 12. Re: populate datalist with xml
                              Scarrfo Level 1

                              Fixed project is located here.

                              I took a quick look at it and corrected a few things for you. There is a read.txt in the zip file that explains a bit more.

                               

                              There were two problems.

                               

                              The xml was not bound to the Main.mxml file or any of the control objects.

                               

                              The xml file was not in a valid xml structure. (It also contained hundreds of various whitespace characters, primarily tab and vertical tab)

                              This means that even if the xml file was bound to the Main.mxml file the data would not render.

                               

                              I am going to let you perform the remaining binding on the listbox but the text boxes and movie are working fine.

                              Enclosed is a simple msaccess database (test.mdb) with columns matching your xml file. To ensure your xml data structure is valid you can enter some test data in and export to xml from msaccess. If you must hand edit the xml you really should validate the xml file prior to using in your project. There are free online ones available and easy to find through a google search.

                               

                              For test purposes I have bound the controls to new and valid xml file. It is included and found in the src directory. The filename is xmlTest.xml  You may need to change the project settings to map to your folder structure but should be able to simply open flash builder then open the project.

                               

                              I removed the .flv file from the mp3psd4\bin-debug directory to save space (upload taking too long) but left a copy in the src folder group so you can build it and run it to see what you have remaining to do.

                               

                              Take care.