2012-08-03 68 views
1

我正在寻找一个类似于iOS上的UIScrollView的as3类;即。你可以拖动视图的任何地方(影片剪辑),它会滚动内容。我发现ScrollPane课程,但它只有一个右边的栏,您必须拖动栏或按向上和向下箭头。我想要一个直观的类,你可以在任何地方滑动以滚动视图。那里有什么吗?我很惊讶,我找不到通过搜索。as3 component like iOS'UIScrollView

为了记录,我看到this question,但其接受的答案链接到一个拙劣的UITableView实现,而不是UIScrollView。

+0

你说得对,有没有什么好的的在那里。我最后写了自己的文章,但是在这里作为回答发布太大了。也许当我有空时,我会把它打包并提供给社区 – BadFeelingAboutThis 2012-08-03 16:41:02

回答

-1

这工作对我来说,它没有评论,但它相当简单。 所有的.fla(不包括)都有一个名为scroll_container的MC包含所有的项目。

private var hasScrolled:Boolean = false; 
    private var checkForScroll:Boolean = false; 
    private var oldMouse:Point; 

    public function IOSScrollTest() { 

     addEventListener(MouseEvent.MOUSE_DOWN, MouseDown); 
     addEventListener(MouseEvent.MOUSE_UP, MouseUp); 
     addEventListener(Event.ENTER_FRAME, EnterFrame); 
    } 

    private function MouseDown(e:MouseEvent) { 

     hasScrolled = false; 
     checkForScroll = true; 
     oldMouse = new Point(mouseX, mouseY); 
    } 

    private function MouseUp(e:MouseEvent) { 

     if(! hasScrolled) { 

      // Do your stuff here (onClick things) 
     } 

     checkForScroll = false; 
    } 

    private function EnterFrame(e:Event) { 

     if(checkForScroll) { 

      var diff:Number = mouseY - oldMouse.y; 
      if(Math.abs(diff) > 2) { 

       hasScrolled = true; 
       oldMouse = new Point(mouseX, mouseY); 
       scroll_container.y += diff; 
      } 
     } 
    }