带参数的滚动条失败

时间:2014-07-08 17:04:01

标签: actionscript-3 flash actionscript scrollbar

通常简单的任务的另一个有趣的问题:滚动条。对于初学者,我知道需要在startDragging函数中放置一个Enter_Frame函数,以便滚动代码起作用。麻烦的是,我无法做到那么远。

以下是代码:

import flash.geom.Rectangle;
import flash.events.MouseEvent;


//establishes the size of the scroller knob
var contPERC = Math.round(text_mc.mask_mc.height / text_mc.content_mc.height * 100);
var knobHeight = contPERC;
scrollbar_mc.scroller_mc.height = knobHeight;
scrollbar_mc.scroller_mc.buttonMode = true;

//establishes the length of the scroll track bar
var trackHeight = scrollbar_mc.strip_mc.height;
var trackY = scrollbar_mc.scroller_mc.y;
var boundHeight = Math.round(trackHeight - knobHeight);
var boundsRect:Rectangle = new Rectangle(0, boundHeight, 0, 0);

//adds the listeners
scrollbar_mc.scroller_mc.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
scrollbar_mc.scroller_mc.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
scrollbar_mc.scroller_mc.addEventListener(MouseEvent.MOUSE_OUT, stopDragging);


function startDragging(){
    scrollbar_mc.scroller_mc.startDrag(false, boundsRect);
    text_mc.content_mc.y = Math.round((scrollbar_mc.scroller_mc.y / 100) * text_mc.content_mc.height)
}

function stopDragging(){
    scrollbar_mc.scroller_mc.stopDrag();
}

但是当我点击scroller_mc时,我得到了这个:

ArgumentError: Error #1063: Argument count mismatch on Scrollbar_fla::MainTimeline/startDragging(). Expected 0, got 1.

1 个答案:

答案 0 :(得分:2)

缺少参数:

function startDragging(e:MouseEvent){ //<-

你的stopDraggin函数也一样。