Basically the idea sounds right in my head.. Get the percentage of the scroll bar knob versus the scrollable area on the scrollbar.. Then treat the height of the content to be scrolled as 100% and convert some percentages around.. but it turns out to be a code mess D:
// Offsets defined by refresh var $offsetA:Number = 0;//$offsetA: is a scrollValue var $offsetBa:Number = 0; var $offsetBb:Number = 0;//$offsetBb: is a scrollValueCounter point the percentage revlant to the message boxes var $offsetCa:Number = 0; var $offsetCb:Number = 0; var $offsetD:Number = 0;
var boundsRectangle:Rectangle; var Enabled:Boolean = false;
this.addEventListener(MouseEvent.MOUSE_DOWN, Scroll_START) this.addEventListener(Event.ENTER_FRAME,setScroll) stage.addEventListener(MouseEvent.MOUSE_UP, Scroll_END)
function Scroll_START($pass:Event) { if (Enabled) { Top_Layer.slider.startDrag(false, boundsRectangle) } } function Scroll_END($pass:Event) { if (Enabled) { Top_Layer.slider.stopDrag() } } function Refresh() { this.Top_Layer.slider.height = 353 * (this.Top_Layer.height / MovieClip(this.parent).Messages.height) boundsRectangle = new Rectangle(-0.5,12.8,0,(353 - (this.Top_Layer.slider.height +26)))
$offsetBa = MovieClip(this.parent).Messages.y; $offsetBb = MovieClip(this.parent).Messages.height; $offsetCa = this.Top_Layer.slider.y; $offsetCb = this.Top_Layer.slider.height; trace(this.Top_Layer.slider.height) trace(this.Top_Layer.height) trace(MovieClip(this.parent).Messages.height) trace(MovieClip(this.parent).Messages.y) Enabled = true;
} function setScroll(event:Event) { if (boundsRectangle) {
$offsetA = (this.Top_Layer.slider.y-$offsetCa) / boundsRectangle.height; MovieClip(this.parent).Messages.y =(($offsetBb * $offsetA)*-1) trace($offsetBb) trace($offsetA) trace($offsetBb * $offsetA) trace(($offsetBb * $offsetA)*-1+$offsetBb) } }
Sadorath · Sat Feb 26, 2011 @ 03:43am · 1 Comments |