5 Replies Latest reply on Oct 19, 2010 9:42 AM by Ned Murphy

    as2 setStyle syntax?

    Rezu Level 1

      Howdy!

       

      Can anyone point me in the direction of a "be all end all" list of setStyle syntax for as2?

       

      Specifically, I'm trying to change the border size of a text box.

       

      Thanks!

       

      kve

        • 1. Re: as2 setStyle syntax?
          Ned Murphy Adobe Community Professional & MVP

          Flash has a limited set of styles that it supports ala the setStyle method of the StyleSheet class.  You can find them all listed in the StyleSheet class section of the help documents, which someone has made available via the following link...

           

          http://flash-reference.icod.de/TextField/StyleSheet.html

           

          But I don't believe you use setStyle to set the border property of a textfield.  And I don't believe you can adjust the thickness of the border.  Here's a link to something that might help though, it involves drawing a border instead of using the textfield's border...

           

          http://thedailyreviewer.com/design/view/textfield-border-thickness-111756529

           

          And I may be wrong, so someone else may have a solution to offer.

          1 person found this helpful
          • 2. Re: as2 setStyle syntax?
            Rezu Level 1

            Hi Ted,

             

            Thanks for the suggestions. I am able to generate a border w/out ticking 'show border' in the textfield properties via...

             

            tf.background = true;
            tf.backgroundColor = 0xd5cb99;
            tf.border = true;
            tf.borderColor = 0x8cb7c7;

             

            But you're right if I try to add something like...      tf.borderWidth = '(Number:5)';       ...I get nothing.

             

             

            So, using the info from the second link you gave, what would be the minimum codage needed to recreate what I have shown above?

            I'll put it below, in case others would like to weigh in.  Thanks!

             

             

             

            var textClip_mc:MovieClip = this.createEmptyMovieClip("textClip_mc",
            this.getNextHighestDepth())
            var theText_mc:MovieClip = this.createEmptyMovieClip("theText_mc",
            this.getNextHighestDepth())
            var borderColor:Number = 0x33333ff;
            var borderSize:Number = 8;
            var backgroundColor:Number = 0xcccccc;
            var textWidth:Number = 200;
            var gutter:Number = 4;
            var theText_txt:TextField =
            theText_mc.createTextField("theText_txt",theText_mc.getNextHighestDepth(),border
            Size,borderSize,textWidth,0);

             

            theText_txt.autoSize = true;
            theText_txt.wordWrap = true;
            theText_txt.multiline = true;
            theText_txt.html = true;
            theText_txt.htmlText = "Lorem ipsum dolor sit amet, consectetur adipisicing
            elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
            enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
            ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
            velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
            cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
            laborum. "
            trace(theText_mc._height)

             

            textClip_mc.beginFill(borderColor);
            textClip_mc.moveTo(0, 0);
            textClip_mc.lineTo(textWidth + borderSize * 2 + gutter, 0);
            textClip_mc.lineTo(textWidth + borderSize * 2 + gutter, theText_mc._height +
            borderSize * 2 + gutter);
            textClip_mc.lineTo(0, theText_mc._height + borderSize * 2 + gutter);
            textClip_mc.lineTo(0, 0);
            textClip_mc.endFill();

             


            textClip_mc.beginFill(backgroundColor);
            textClip_mc.moveTo(borderSize, borderSize);
            textClip_mc.lineTo(textWidth + borderSize + gutter, borderSize);
            textClip_mc.lineTo(textWidth + borderSize + gutter, theText_mc._height +
            gutter + borderSize);
            textClip_mc.lineTo(borderSize, theText_mc._height + gutter + borderSize);
            textClip_mc.lineTo(borderSize, borderSize);
            textClip_mc.endFill();

            • 3. Re: as2 setStyle syntax?
              Ned Murphy Adobe Community Professional & MVP

              The minimum needed would not involve creating as many dynamic elements or other formatting that that code provides.  I haven't looked too far into it, but I think all you really need is this section, and you would have to adjust the points it specifies based on the location of the textfield (this example has the border being drawn relative to the 0,0 corordinate inside the textClip_mc)...

               

              // assuming textClip_mc already exists

               

              textClip_mc.beginFill(borderColor);
              textClip_mc.moveTo(0, 0);
              textClip_mc.lineTo(textWidth + borderSize * 2 + gutter, 0);
              textClip_mc.lineTo(textWidth + borderSize * 2 + gutter, theText_mc._height +
              borderSize * 2 + gutter);
              textClip_mc.lineTo(0, theText_mc._height + borderSize * 2 + gutter);
              textClip_mc.lineTo(0, 0);
              textClip_mc.endFill();

              • 4. Re: as2 setStyle syntax?
                Rezu Level 1

                Great! Thanks so much Ned!

                • 5. Re: as2 setStyle syntax?
                  Ned Murphy Adobe Community Professional & MVP

                  You're welcome