# Custom FLV Scrubber

**URL:** <https://forum.kirupa.com/t/custom-flv-scrubber/264726>\
**Category:** flash\
**Created:** [June 29, 2008, 5:47pm UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726 "2008-06-29T17:47:27Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayrich86](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jayrich86](https://forum.kirupa.com/u/jayrich86)\
**Post date:** [June 29, 2008, 5:47pm UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/1 "2008-06-29T17:47:27Z")

</div>

For some reason my scrubber won’t scrub correctly while the video is loading, but once it has completed it scrubs just fine. Here is my code

```auto
                    var scrubInterval;
                    var videoInterval = setInterval(videoStatus, 100);
                    var newTime:Number;
                    var amountLoaded:Number;

                    ns["onMetaData"] = function (obj) {
                        duration = obj.duration;
                    };

                    mediaPanel.loader_mc.loadbar_mc.onPress = function():Void {
                        clearInterval(videoInterval);
                        scrubInterval = setInterval(scrubit, 10);

                    };
                    mediaPanel.loader_mc.loadbar_mc.onRelease = function():Void {
                        clearInterval(scrubInterval);
                        videoInterval = setInterval(videoStatus, 100);

                    };

```

Here is are the videostatus and scrubit functions

```auto
 var duration:Number;

function videoStatus():Void {
    amountLoaded = ns.bytesLoaded/ns.bytesTotal;
    mediaPanel.loader_mc.loadbar_mc._xscale = amountLoaded*100;
    mediaPanel.loader_mc.scrub_mc._xscale = (ns.time/duration)*100;

}

function scrubit():Void {
    newTime = (mediaPanel.loader_mc.back_mc._xmouse/298)*duration;
    trace(newTime);
    ns.seek(Math.floor(newTime));
} 

```

Here is the site that im working on [http://mav-media.com/Maverick](http://mav-media.com/Maverick) click on portfolio, then the first thumbnail under “motion”

and thoughts welcome.

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 30, 2008, 8:23am UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/2 "2008-06-30T08:23:24Z")

</div>

scrubbers are a little bit off until it has fully loaded, but yours is fairly bad.

gotoandlearn…

---

<div class="post-metadata">

**Author:** ![jayrich86](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jayrich86](https://forum.kirupa.com/u/jayrich86)\
**Post date:** [June 30, 2008, 4:14pm UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/3 "2008-06-30T16:14:27Z")

</div>

Thanks, I actually followed that tutorial to begin with, anything in my code that may be incorrect or causing this result :S?

[quote=randomagain;2351221]scrubbers are a little bit off until it has fully loaded, but yours is fairly bad.

gotoandlearn…[/quote]

---

<div class="post-metadata">

**Author:** ![jibble](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jibble/32/2265_2.png) [@jibble](https://forum.kirupa.com/u/jibble)\
**Post date:** [June 30, 2008, 6:06pm UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/4 "2008-06-30T18:06:42Z")

</div>

Why not just edit and rename a default scrubber? I’ve made countless numbers of these and the default ones are relatively easy to edit and customize.

I did have one problem that happened from encoding a rather large video similar to yours being “a bit off”. it seemed that the scrubber wouldn’t work until it was fully loaded, but it turns out sometimes the flv encoding method looses data. There is a tool that i used that fixed the problem. I don’t know it off hand but if you need it hit me with a pm.

---

<div class="post-metadata">

**Author:** ![jayrich86](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jayrich86](https://forum.kirupa.com/u/jayrich86)\
**Post date:** [July 1, 2008, 3:32pm UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/5 "2008-07-01T15:32:56Z")

</div>

What tool? Could you explain what you mean by the default scrubber? Thanks

[quote=jibble;2351435]Why not just edit and rename a default scrubber? I’ve made countless numbers of these and the default ones are relatively easy to edit and customize.

I did have one problem that happened from encoding a rather large video similar to yours being “a bit off”. it seemed that the scrubber wouldn’t work until it was fully loaded, but it turns out sometimes the flv encoding method looses data. There is a tool that i used that fixed the problem. I don’t know it off hand but if you need it hit me with a pm.[/quote]

---

<div class="post-metadata">

**Author:** ![jibble](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jibble/32/2265_2.png) [@jibble](https://forum.kirupa.com/u/jibble)\
**Post date:** [July 1, 2008, 3:40pm UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/6 "2008-07-01T15:40:49Z")

</div>

> **[Fix Your .FLV Files](https://hubpages.com/art/flv-2)**
>
> .FLV or "Flash Video" is the greatest video format around for web viewing purposes. Supported by the vast majority of browsers and critical to the social video networking scene, it is nearly guaranteed to work on all of your visitors' computers. ...

  
i have had to use the FLV MetaData Injector GUI 1.05 to fix a few of my flv’s. Seems to be the bigger ones ~15 mins or bigger that i’ve had issues with, but you might want to try it.

As for the actual design and look of the scrubber. Take one of the flash default scrubbers and just edit it. Should be here(for CS3 anyway)…

C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\FLVPlayback Skins\FLA\ActionScript 2.0

copy and paste one or two of those scrubber .fla’s that would be easiest for you to edit and mess around with it. Basically just re-skin it.

---

<div class="post-metadata">

**Author:** ![jayrich86](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jayrich86](https://forum.kirupa.com/u/jayrich86)\
**Post date:** [July 2, 2008, 10:42pm UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/7 "2008-07-02T22:42:09Z")

</div>

i dont want to use the flv component though, any other suggestions on why this isn’t working for me?

---

<div class="post-metadata">

**Author:** ![creatify](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@creatify](https://forum.kirupa.com/u/creatify)\
**Post date:** [July 2, 2008, 11:25pm UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/8 "2008-07-02T23:25:51Z")

</div>

it looks like, on press the red bar tries to go to the mouse, but then backs up to where it thinks it should be playing. If this is correct, I kinda think its the videoStatus method.  
in the following:

```auto

newTime = (mediaPanel.loader_mc.back_mc._xmouse/298)*duration;

```

- is 298 the total width of your progress bar?
- is the newTime tracing appropriately while its loading - and its in milliseconds?
- are you clearning your intervals correctly? looks like both are always running
- could it me your \_xmouse target - mediaPanel (don’t see how that could change)

In the videoStatus method, trace all of these out:  
amountLoaded  
amountLoaded\*100;  
ns.time  
duration

see if anything is undefined. I’ve had issues with metadata too, sometimes loading, sometimes not. Also, the metadata seems to lag on loading some times. So if duration isn’t tracing in videoStatus, that seems like it would cause something like whats happening.

---

<div class="post-metadata">

**Author:** ![jayrich86](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jayrich86](https://forum.kirupa.com/u/jayrich86)\
**Post date:** [July 13, 2008, 2:33am UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/9 "2008-07-13T02:33:29Z")

</div>

1. 298 is the total width
2. newTime is tracing correctly (in seconds, not miliseconds)
3. I think I am clearing them correctly, I’m using clearInterval
4. all those variables are tracing correctly including duration :S

---

<div class="post-metadata">

**Author:** ![project107](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@project107](https://forum.kirupa.com/u/project107)\
**Post date:** [July 13, 2008, 8:43pm UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/10 "2008-07-13T20:43:27Z")

</div>

Use an onEnterFrame instead of setInterval to fire the scrubbing functions.

---

<div class="post-metadata">

**Author:** ![jayrich86](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jayrich86](https://forum.kirupa.com/u/jayrich86)\
**Post date:** [July 14, 2008, 1:59am UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/11 "2008-07-14T01:59:44Z")

</div>

> [@project107;2357944](#):
>
> Use an onEnterFrame instead of setInterval to fire the scrubbing functions.

could you show me how with as 2.0?  
thank you

---

<div class="post-metadata">

**Author:** ![project107](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@project107](https://forum.kirupa.com/u/project107)\
**Post date:** [July 14, 2008, 2:02pm UTC](https://forum.kirupa.com/t/custom-flv-scrubber/264726/12 "2008-07-14T14:02:10Z")

</div>

Your code looks like gotoandlearn’s tutorial code, and consequently, this code comes from Lee’s blog:

```auto

this.createEmptyMovieClip("vFrame",this.getNextHighestDepth());
vFrame.onEnterFrame = videoStatus;
var amountLoaded:Number;
var duration:Number;
ns["onMetaData"] = function(obj) {
duration = obj.duration;
}
function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * 208.9;
loader.scrub._x = ns.time / duration * 208.9;
}
loader.scrub.onPress = function() {
vFrame.onEnterFrame = scrubit;
this.startDrag(false,0,this._y,208,this._y);
}
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {
vFrame.onEnterFrame = videoStatus;
this.stopDrag();
}
function scrubit() {
ns.seek(Math.floor((loader.scrub._x/208)*duration));
}

```
