Posted By

lzyy on 04/17/09


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dubogii


滚动条制作


 / Published in: ActionScript 3
 

在startDrag时,监听stage的mouse up事件,这样,在滚动条外部松开时,也能停止滚动条的滚动,同时还要监听ENTER_FRAME事件,来更新滚动区的位置

  1. tuodongtiao.addEventListener(MouseEvent.MOUSE_DOWN, _onDrag);
  2. private function _onDrag(e:MouseEvent)
  3. {
  4. var t:MovieClip = MovieClip(e.target);
  5. t.startDrag(false, new Rectangle(430, 0, 0, 400));
  6. t.addEventListener(Event.ENTER_FRAME, _onDragerEnterFrame);
  7. stage.addEventListener(MouseEvent.MOUSE_UP, _onStopDrag);
  8. }
  9. private function _onStopDrag(e:MouseEvent)
  10. {
  11. stage.removeEventListener(MouseEvent.MOUSE_UP, _onStopDrag);
  12. tuodongtiao.stopDrag();
  13. }
  14. private function _onDragerEnterFrame(e:Event)
  15. {
  16. var t:MovieClip = MovieClip(e.target);
  17. var delta = t.y * (car.lingdong.ceng.wenziMc.wenzi.textHeight - 380) / 400;
  18. if (delta > 0)
  19. {
  20. car.lingdong.ceng.wenziMc.y = car.lingdong.ceng.wenziMc.originY - delta;
  21. }
  22. }

Report this snippet  

You need to login to post a comment.