2012-05-30 1 views
0

스티브 r런 덴의 우수 기사 http://flexponential.com/2009/10/09/changing-the-position-of-the-scroll-bars-in-a-spark-list/에 대한 VScrollBar의 스크롤러 스킨을 수정하여 스크롤 바가없는 위쪽 및 아래쪽 버튼 만 있습니다.플렉스 스파크 스크롤러를 페이지 단위로 스크롤하여 여백 변경

이제 스크롤러의 동작을 수정하여 클릭당 한 페이지를 스크롤합니다. 더 나은 점은 스크롤링을 페이지에서 페이지로 이동하지 않고 애니메이션으로 스크롤하여 여유있게 움직이게하고 싶습니다.

ScrollBarBase http://www.flex-component.com/asdoc/kcdualslider/spark/components/supportClasses/ScrollBarBase.html에 대한 문서는이를 달성 할 수있는 수단을 제공해야한다 메소드를 제안하지만, 나는이 우수한 메서드와 속성을 사용하는 방법의 예를 찾을 수 없습니다 :

animatePaging(newValue:Number, pageSize:Number): 
    Animates the operation to move to newValue. 

button_buttonDownHandler(event:Event): 
    Handles a click on the increment or decrement button  

button_buttonUpHandler(event:Event): 
    Handles releasing the increment or decrement button 

decrementButton:Button 
    An optional skin part that defines a button that, when pressed, steps the scrollbar up. 

incrementButton:Button 
    An optional skin part that defines a button that, when pressed, steps the scrollbar down. 

내 hunch는 decrementButton과 incrementButton을 호출하고 animatePaging을 호출하기 위해 button_buttonUp/DownHandlers를 인터럽트해야한다는 것입니다.하지만 실제로 어떻게해야하는지 모릅니다. 이 스파크 스킨은 AS3을 작성하고 스킨을 성공적으로 수정 했음에도 불구하고 정말로 신비스럽지 않게되었습니다.

통찰력을 기대합니다!

감사합니다.

답변

1

내 질문에 대한 해결책을 찾았습니다.

VScrollBar 클래스를 확장해야했습니다. 일단 이렇게하면 button_buttonDown/UpHandlers를 재정의하는 것이 간단합니다.

내 피부에서 VScrollBar를 클래스를 확장하는 데, 나는

<my_namespace:CustomVScrollBar for <s:VScrollBar 

가 여기 내 CustomVScrollBar의 요점입니다 교체. gs.TweenLite를 사용하고 있지만 애니메이션의 트위너를 사용할 수 있습니다.

package my_package { 

    import flash.events.Event; 
    import gs.TweenLite; 
    import spark.components.VScrollBar; 



    public class CustomVScrollBarextends VScrollBar 
    { 

     public function CustomVScrollBar() 
     { 
      super(); 
     } 



     override protected function button_buttonDownHandler(event:Event):void { 
      var valueTo:Number; 
      if (event.target == incrementButton) { 
       valueTo = Math.min(value+pageSize, maximum); 
      } else if (event.target == decrementButton) { 
       valueTo = Math.max(value-pageSize, minimum); 
      } 
      if (! isNaN(valueTo)) { 
       TweenLite.to(this.viewport, .75, {verticalScrollPosition: valueTo}); 
      } 
     } 

     override protected function button_buttonUpHandler(event:Event):void { 
      // 
      // nothing 
     } 

    } 
} 
관련 문제