Reputation: 9
Another fun question for a usually simple task: a scrollbar. For starters, I'm aware that an Enter_Frame function needs to be placed in the startDragging function in order for the scrolling code to work. Trouble is, I can't get that far.
Here's the code:
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();
}
but when I click on scroller_mc, I get this:
ArgumentError: Error #1063: Argument count mismatch on Scrollbar_fla::MainTimeline/startDragging(). Expected 0, got 1.
Upvotes: 0
Views: 42
Reputation: 4665
Missing argument:
function startDragging(e:MouseEvent){ //<-
Same for your stopDraggin function.
Upvotes: 2