5 Replies Latest reply on Jul 26, 2010 8:43 AM by Vie Bone

    get s:Application verticalscrollposition

    Vie Bone Level 1

      Hello!

       

      Someone know how could I get the verticalScrollPosition of an elment inside of an s:Application with scroll.

       

      What i want to do is to leave a container allways at the footer of the browser window no matter what height the flex app has. And i think that to achieve this first a have to know the verticalscrollposition of the container relative to the app scroll, but i don't have a scroller element because a give the scroll to the app with the skinning.

       

      thanks!

       

      I set up the scroll of the s:Application skinning it as follows here:

       

       

       

      <s:Scroller id="appScroller" width="100%" height="100%" hasFocusableChildren="true" horizontalScrollPolicy="off">

       

       

       

      <s:Group id="contentGroup"

      left="

      0" right="0"

      top="

      0" bottom="0">

       

       

      <s:layout>

       

       

      <s:VerticalLayout horizontalAlign="center">

       

       

       

      </s:VerticalLayout>

       

       

      </s:layout>

       

       

       

      </s:Group>

       

       

       

      </s:Scroller>

        • 1. Re: get s:Application verticalscrollposition
          Anuradha@

          Place all your components along with the footer in a Vbox(id="vb").Do not give any height to this Vbox.Only specify width="100%".Say your footer component is a Panel(id="pan").At creationComplete of your Application write one method and include the following code-:

          if

           

           

           

           

          (vb.height>this.height)

          {

          pan.y=vb.height-pan.height;

          }

          else

          pan.y=

          this.height-pan.height;

          • 2. Re: get s:Application verticalscrollposition
            Vie Bone Level 1

            Hey thanks!

             

            I can't test it know but sounds easy, i'll try it at soon as i get back to my office.

             

            Thanks!

            • 3. Re: get s:Application verticalscrollposition
              Vie Bone Level 1

              Hello!

               

              Thanks, it works great!!!

               

              Each step forward that I make I find an other obstacle.

               

              How could I keep this panel at the same position all time? I mean, if i do scroll, the container move with it, how could I fix it at the bottom of the browser?

               

              thanks a lot

              • 4. Re: get s:Application verticalscrollposition
                Anuradha@ Level 1

                Try this...hope this helps...

                <mx:VBox

                 

                height="100%" width="100%">

                 

                <mx:Canvas width="100%" height="75%">

                 

                <mx:VBox id="vb" width="98%" height="100%">

                 

                <mx:Panel id="pan1" height="100" width="100%"/>

                 

                <mx:Panel id="pan2" height="100" width="100%"/>

                 

                </mx:VBox>

                 

                </mx:Canvas>

                 

                <mx:Canvas height="25%" width="100%">

                 

                <mx:Panel title="Footer" width="100%" height="100%"/>

                 

                </mx:Canvas>

                 

                </mx:VBox>

                 

                 

                You can place all your components inside "vb" without disturbing position of footer panel.

                • 5. Re: get s:Application verticalscrollposition
                  Vie Bone Level 1

                  Thanks Anuradha@,

                   

                  I am close to achieve what I am looking for.

                   

                  Using your system and improving your code to listen to the app skin scroll I am very close, but, I can't do it smoothly, I explain a bit:

                   

                  The problem is that my app must have a scroll, and I need the floating pannel to be in the same position all time, I can't put the scroll in a container, It must be in the app skin.

                   

                  I put all in a box (y used a spark Group instead of a VBox).

                   

                  In the skin I  added a script that is listening to the scroll, adding a PropertyChangeEvent to the scroll.viewport and passing its value to the hostComponent.

                   

                  In the component I set up a EnterFrame Event that check the value passed from the skin.

                   

                  All is working fine, the floating container is always at the footer of the browser, but, if I drag the scroll, the floating container start jumping, the floating pannel begin following the scroll, it move with all the content and sudenly jump to the correct position, it seems like if with the drag, the event listener doesn't receive any values from the scroll.

                   

                  My question now is, does anybody know how could I create a completly smooth scroll??????

                   

                  I have been searching the forum and google but I didn't find an answer for that.

                   

                  Thanks again.