6 Replies Latest reply on Jul 10, 2006 7:59 AM by sbryner

    Scrollbar Visibility

    sbryner Level 1
      Hey everyone,

      I'm delving into scrolling text. I have a uiScrollBar component. instance name "scrollBar" attached to my
      dynamic text field, instance name "infoBox_txt".

      My problem is I want the "scrollBar" to disappear when the text in my field does not fill the text field.
      I don't know if I should put it in an onLoad or what?

      Here's what I've thought it might look like as a function called

      function uiScrollCheck () {
      if(infoBox_txt.text = null) {
      scrollbar.visible=false;
      }
      }

      I've looked in the help section but it seems kinda vague as to where it should/could go.

      any help is great.

      Thanks,

      Sky
        • 1. Re: Scrollbar Visibility
          Sivakanesh Level 1
          if you simply want to hide or show the scrollbar based on the length of text inside infoBox_txt then it would be better to use an event.
          For example place this on frame 1
          infoBox_txt.onChanged = function ()
          {
          if(infoBox_txt.length < 10) {
          scrollbar.visible=false;
          }
          }

          Now every time the text box changes of the number of characters is less than 10 the scrollbar will remain hidden.
          • 2. Re: Scrollbar Visibility
            sbryner Level 1
            Thanks for the code. I tried it and it doesn't work for me.

            Here is my code: (which should mean if 6 or more characters are in the infoBox_txt then it should turn on the scrollBar.visible=true, correct?

            What could be preventing this from working? I only have one frame in my .swf.

            infoBox_txt.onChanged =function () {
            if(infoBox_txt.length < 5) {
            scrollBar.visible = false;
            }
            }


            thanks,

            sky
            • 3. Re: Scrollbar Visibility
              Craig Grummitt Level 3
              onChanged only activates on user interaction, so if you've got a dynamic text box (i.e. not an input text box) this event will never occur. you'd be better off putting the code directly after your code manipulates the text in the text box. i.e. the line that begins:
              infoBox_txt.text=
              • 4. Re: Scrollbar Visibility
                Sivakanesh Level 1
                Yeah Craig is right, I over looked that it was a dynamic textfield.
                Anyway you can still modify the code to work based on the length of the text.

                If you put this code where ever you are either assigning text to infoBox_txt or clearing it you should get the desired effect. In fact you may even want to add this to the frame1 of your movie at initialisation.

                if(infoBox_txt.length < 5) {
                scrollBar.visible = false;
                }

                Does this help?
                • 5. Re: Scrollbar Visibility
                  Craig Grummitt Level 3
                  after looking at this again, i've realised you would be most interested about whether the text in the textbox is smaller/larger than the area available to display it than the number of characters in the text box, so you might prefer to use: (this of course assumes vertical scrolling)
                  • 6. Re: Scrollbar Visibility
                    sbryner Level 1
                    Thanks for the help. I've been on vacation and will try your suggestions. Thanks again.