scroll bar start position
hey guys,
So i created a custom scroll bar which works fine and all... the problem with it is with the space i have it confined to. The scroll bar doesnt start at the top of the space, but rather about 10 pixels down. I'm sure it has to do with my math or something, but I'm pretty clueless. Here's the code:
---------------------------------------------------------------
/*Text Field Scroller Starts Here*/
var myText:TextField = new TextField();
var myFormat:TextFormat = new TextFormat();
myFormat.font = "Ariel";
myFormat.color = 0*818146;
myFormat.size = 16;
addChild(myText);
myText.text = "TEXTTEXTTEXTTEXTTEXTTEXTTEXT.. etc";
myText.setTextFormat(myFormat);
myText.wordWrap = true;
myText.multiline = true;
myText.setTextFormat(myFormat);
myText.x = 323.9;
myText.y = 217.13;
myText.width = 417;
myText.height = 223;
/*Scroll Arrows*/
scrollUP.addEventListener(MouseEvent.CLICK, upScroll);
function upScroll(event:MouseEvent):void
{
myText.scrollV -= 1;
}
scrollDown.addEventListener(MouseEvent.CLICK, downScroll);
function downScroll(event:MouseEvent):void
{
myText.scrollV += 1;
}
//slider
slider.addEventListener(MouseEvent.MOUSE_DOWN, dragSlider);
stage.addEventListener(MouseEvent.MOUSE_UP, dropSlider);
var bounds:Rectangle = new Rectangle(slider.x, slider.y, 0, 170);
var dragging:Boolean = false;
function dragSlider(event:MouseEvent):void
{
slider.startDrag(false,bounds);
dragging = true;
}
function dropSlider(event:MouseEvent):void
{
slider.stopDrag();
dragging = false;
}
function checkSlider(event:Event):void
{
myText.scrollV = Math.round ((slider.y - bounds.y)* myText.maxScrollV/170)
}
stage.addEventListener(Event.ENTER_FRAME, checkSlider);
function textScrolled(event:Event):void
{
slider.y = bounds.y + (myText.scrollV * 170/myText.maxScrollV);
}
myText.addEventListener(Event.SCROLL, textScrolled);
--------------------------------------------------------------
I hope that helps. Maybe just the part from //slider down is the part i should be focusing on but I dont know what to do. Let me know if I need to provide more.
--L