3 Replies Latest reply on Aug 4, 2009 10:22 AM by Gregory Lafrance

    Flex 3 Database & Large Html Files

    jk@bbcan.org

      Hi Guys,

       

      New to flex, and I have a question, any help would be much appreaciated, I have a database sql server 2005 I use web orb to connect to it throu flex, I have books stored in this database each page of a book is a seperate record and has html tags throughout it, what I would like to do is display one page at a time to the user and then have them click a button to get to the next record or page, this I could manage in a datagrid I guess but the pages of text are quite large is there a component that would better suit a large page of text such as the text component if so could you give me an example of how to bind my data to it and how to stop the html tags showing up as text, or if I could customize the layout of the datagrid that might be a better solution.

       

       

      I have posted an attempt to use a text component but have been unsuccessful thus far:

       

       

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

              <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" title="The Lord Is Near">
              <mx:Script>
      <![CDATA[
                      import mx.collections.ArrayCollection;
                      import AlphaOmega.ActiveRecords;
                      import AlphaOmega.Alpha_Calendar;
                      import mx.controls.TextArea;

                                    
                      public function GetTodaysLin():ArrayCollection
                     
                      {
                              return ActiveRecords.Alpha_Calendar.findBySql("SELECT Cal_ID, Cal_Text, Cal_Date, Cal_MP3 FROM Alpha_Calendar WHERE (Cal_Date = CONVERT(VARCHAR(30), GETDATE(), 102))");
                      }
              ]]>
      </mx:Script>   
              <mx:Text htmlText="{GetTodaysLin}" width="100%" height="100%" id="Lin" />
             

      </mx:Panel>

       

       

      Thanks

        • 1. Re: Flex 3 Database & Large Html Files
          Gregory Lafrance Level 6

          You seem to be using Text with htmlText property. Does that not display the HTML as expected? Remember, Flex supports a sub-set of HTML tags:

           

          Search for" Using tags in HTML text" in this page:

           

          http://livedocs.adobe.com/flex/3/html/help.html?content=textcontrols_04.html

           

          You could just have Next and Back buttons that populate the Text control from the next of previous item in an ArrayCollection, where the items in the ArrayCollection are objects with each page of text.

           

          If this post answered your question or helped, please mark it as such.

          • 2. Re: Flex 3 Database & Large Html Files
            jk@bbcan.org Level 1

            Thanks Greg,

             

            I cannot seem to get my data to display if I use a text control, but everything works perfectly if I use a datagrid, any ideas as to why it would not display looking at my text control code.

             

            Thanks for your time.

             

            Jonathan

            • 3. Re: Flex 3 Database & Large Html Files
              Gregory Lafrance Level 6

              <mx:Text htmlText="{GetTodaysLin}" width="100%" height="100%" id="Lin" />

               

              GetTodaysLin seems to return an ArrayCollection, but the Text "text" property should probably not be an ArrayCollection. You should probably populate an ArrayCollection at creationComplete, and then initialize the Text control with myAC.getItemAt(currentItemNum), where currentItemNum is a uint variable, then have Next and Back buttons to change the text using currentItemNum++ or currentItemNum--.

               

              currentItemNum should be bindable with [Bindable], and you will need to check to ensure currentItemNum is not < 0 and is not >= myAC.length().

               

              If this post answered your question or helped, please mark it as such.