[Flash 8] Video Player Scrubber

I have created an XML driven Video Player based on Lee Brimelow’s Video Tutorial http://www.gotoandlearn.com/index.php?currentpage=13.

I have a MC called **loader **which contains two MCs- a circular shaped clip called **scrub **which can be used to seek to particular time of the video. and anoder MC called loadbar which denotes the amount of video loaded by expanding correspondingly.

Everything works fine except the video scrubber (the playhead). when the scrubber reaches the end of the movie; instead of stopping at the end of the **loader **MC it goes beyond it.

here’s the code:

function videoStatus() {
    amountLoaded = ns.bytesLoaded/ns.bytesTotal;
    loader.loadbar._width = amountLoaded*650;
    loader.scrub._x = ns.time/duration*650;
}

loader.scrub.onPress = function() {
    clearInterval(videoInterval);
    scrubInterval = setInterval(scrubit, 10);
    startDrag(this, true, 0, this._y, 650, this._y);
};
loader.scrub.onRelease = loader.scrub.onReleaseOutside=function () {
    
    clearInterval(scrubInterval);
    videoInterval = setInterval(videoStatus, 100);
    this.stopDrag();
};
function scrubit() {
    ns.seek(Math.floor((loader.scrub._x/650)*duration));
}

[COLOR=Black]Note:
-650 is the width of the loadclip that depicts the seek bar[/COLOR]
-videoStatus is a function that updates the width of the load bar and the position of the seek bar. it gets called by an setInterval every 100ms

  • scrubit is a function that gets called when the seek head is pressed and draggged along the timeline

Now i think the reason is because in the line

loader.scrub._x = ns.time/duration*650;

when the playhead reaches 650 it’s actually 650+(the width of the playhead.i.e 33px)

i tried solving it by deducting the width of the play head in this line, bt then erytime i dragged the playhead it jumps back a few secs behind on the time line. i think all i need is firgure out a formula that correctly calculates the position.