4 Replies Latest reply on Sep 20, 2010 9:03 AM by chinchiheather

    text scrolls when it shouldn't

    chinchiheather

      I have several Text components added to my application and the value of their text changes depending on different users. I have a problem where if the user uses their mouse wheel to scroll down the page while it is over one of these Text instances then the text seems to scroll up and the first line disappears.

       

      This is really frustrating and I have tried many different things, I was hoping someone would be able to help...

       

      Thank you

        • 2. Re: text scrolls when it shouldn't
          simplesid

          Hi,

          First of all, do you need your components to be selectable? If not, just set the selectable property to false, or you can even use a mx:Label instead. This should stop the scrolling. Hope this helps.

          Thanks,

          Sid.

           

           

          (P.S. If this post helps, please mark it so. )

          • 3. Re: text scrolls when it shouldn't
            Arun Ganesh Level 3

            Try this,

             

            private function stopScrollAction(event:MouseEvent):void{       
                    (event.currentTarget as TextArea).verticalScrollPosition = 0;
                    (event.currentTarget as TextArea).invalidateProperties();
                }

             

              <mx:TextArea  id="ta1" mouseWheel="{stopScrollAction(event)}" fontSize="12" fontWeight="bold" width="300" height="100">
                 <mx:text>
                    This is a test of the emergency broadcast system. It is only a test. This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.This is a test of the emergency broadcast system. It is only a test.
                 </mx:text>
              </mx:TextArea>

            • 4. Re: text scrolls when it shouldn't
              chinchiheather Level 1

              Hi I found that link really helpful, and i managed to solve my problem by creating a custom text box using the code from that link and then just calling this throughout my application. The text did need to be selectable, but also if you set selectable to false the text still scrolls on macs.

               

              So in case anyone else has my problem my component's code looks like:

               

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onInit()">
              <mx:Script>
                      <![CDATA[
                          import mx.events.ScrollEvent;
                          import mx.core.UIComponent;
                          import mx.utils.ObjectUtil;
                          import mx.core.UITextField;
                         
                          private function onInit():void{
                              txtDesc1.text = textValue;
                              txtDesc1.percentWidth = 100;
                                     
                              UITextField(txtDesc1.getChildAt(0)).addEventListener(Event.SCROLL,onScroll);
                              UITextField(txtDesc1.getChildAt(0)).alwaysShowSelection = true;
                          }
                         
                          private function onScroll(event:Event):void{
                              if(UITextField(txtDesc1.getChildAt(0)).scrollV == 2){
                                  UITextField(txtDesc1.getChildAt(0)).scrollV = 1;
                              }
                          }
                         
                          public var textValue:String = "";

               

                      ]]>
                  </mx:Script>
                  <mx:Text id="txtDesc1" width="100%" condenseWhite="true" />
              </mx:Canvas>

               

              and i call it in other files like:

               

                   var text:NotScrollTextBox = new NotScrollTextBox();
                   text.percentWidth = 100;
                   text.textValue = post.message;
                   textBox.addChild(text);

               

              where post.message is just a string whose value changes depending on the user.

               

              Thank you for being really helpful everyone!