# \[Flash 8\] Video Player Scrubber

**URL:** <https://forum.kirupa.com/t/flash-8-video-player-scrubber/317225>\
**Category:** flash\
**Created:** [December 14, 2010, 10:20am UTC](https://forum.kirupa.com/t/flash-8-video-player-scrubber/317225 "2010-12-14T10:20:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![trex](https://avatars.discourse-cdn.com/v4/letter/t/dfb087/32.png) [@trex](https://forum.kirupa.com/u/trex)\
**Post date:** [December 14, 2010, 10:20am UTC](https://forum.kirupa.com/t/flash-8-video-player-scrubber/317225/1 "2010-12-14T10:20:19Z")

</div>

I have created an XML driven Video Player based on Lee Brimelow’s Video Tutorial [http://www.gotoandlearn.com/index.php?currentpage=13](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.  
 ![](http://img714.imageshack.us/img714/2834/scrubber.jpg)  
here’s the code:

```auto
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

```auto
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.
