5 Replies Latest reply on Apr 23, 2006 1:37 PM by kglad

    multicolumn text layout

    Level 7
      hi:

      i have a Flash movie (MX2004) receiving a string containing several
      lines (carriage return separated). i need to show the text in 2 columns

      i'm guessing the problem has probably been solved before and i don't
      need to re-invent the wheel

      thanks in advance for any ideas/suggestions

      jdoe
        • 1. Re: multicolumn text layout
          kglad Adobe Community Professional & MVP
          how is the text to be divided into two columns? is the first part of the text to be in one column and the 2nd part of the text to be in the 2nd column? do one or more of these columns need to scroll to accomodate all the text?
          • 2. Re: multicolumn text layout
            Level 7
            kglad wrote:
            > how is the text to be divided into two columns? is the first part of the text
            > to be in one column and the 2nd part of the text to be in the 2nd column?

            yes, like in a newspaper


            > do one or more of these columns need to scroll to accomodate all the text?

            no scroll needed
            • 3. Re: multicolumn text layout
              kglad Adobe Community Professional & MVP
              if your textfields have instance names tf1 and tf2 (and are non-html), and your file returning your text is test.txt and it's returning the variable yourvar, you can use:

              • 4. Re: multicolumn text layout
                Level 7
                i just needed to make a little modification to avoid the last word in
                the last line of left column appearing in first line of right column
                when there was a car return in it

                the only problem i have found so far is a slow performance with long
                strings (as you can expect with string operations)

                thanks for your help!


                function setDesc(descText) {
                var overflow:Boolean = false;

                for (var i=0; i<descText.length; i++) {
                desc_left.text = descText.substring(0, i);
                if (desc_left.maxscroll>1) {
                overflow = true;
                break;
                }
                }

                if (!overflow) {
                desc_left.text = descText;
                } else {
                if (desc_left.text.charCodeAt(desc_left.text.length-2) == 13) {
                breakPt = desc_left.text.length-2;
                } else {
                breakPt = descText.lastIndexOf(" ", i);
                }
                desc_left.text = descText.substring(0, breakPt);
                desc_right.text = descText.substring(breakPt+1);
                }
                }



                kglad wrote:
                > if your textfields have instance names tf1 and tf2 (and are non-html), and your
                > file returning your text is test.txt and it's returning the variable yourvar,
                > you can use:
                >
                >
                >
                > lv = new LoadVars();
                > lv.onLoad = function() {
                > for (var i = 0; i<this.yourvar.length; i++) {
                > tf1.text = this.yourvar.substring(0, i);
                > if (tf1.maxscroll>1) {
                > break;
                > }
                > }
                > breakPt = this.yourvar.lastIndexOf(" ", i);
                > tf1.text = this.yourvar.substring(0, breakPt);
                > tf2.text = this.yourvar.substring(breakPt+1);
                > };
                > lv.load("test.txt");
                >
                • 5. Re: multicolumn text layout
                  kglad Adobe Community Professional & MVP
                  you're welcome.