Skip to main content
Participant
July 13, 2009
Answered

Scrubber issue. AS 2, Flash CS 3

  • July 13, 2009
  • 1 reply
  • 809 views

Hey there. After following the scrubber tutorial on gotoandlearn I've hit a serious hick-up. Basically instead of scrubbing, if I grab and move my "scrub" it literally just pauses the video, and once I've let go, returns to the beginning?


I've narrowed the problem down to the "scrubit" function and the script for that function but unfortunately can't seem to solve it. Any help out there?

Here's the whole code:

/*loadbar*/
var videoInterval = setInterval(videoStatus,100);
var amountLoaded:Number;
var duration:Number;

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

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

var scrubInterval;

loader.scrub.onPress = function()
{
    clearInterval(videoInterval);
    scrubInterval = setInterval(scrubit,10);
    this.startDrag(false,0,this._y,336.6,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/336.6) * duration);
}

In bold is what I think the problem is.

Any help, comments are much appreciated.

Luke.

This topic has been closed for replies.
Correct answer Ned Murphy

ns.seek(Math.floor(loader.scrub._x/336.6) * duration);

I don't normally deal with video matters so I may be totally off with this, but if the value of loader.scrub._x is less than 336.6 then the Math.floor value will be 0, which will result in ns.seek(0);

What you might intend is...

ns.seek(Math.floor(loader.scrub._x/336.6 * duration));

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
July 13, 2009

ns.seek(Math.floor(loader.scrub._x/336.6) * duration);

I don't normally deal with video matters so I may be totally off with this, but if the value of loader.scrub._x is less than 336.6 then the Math.floor value will be 0, which will result in ns.seek(0);

What you might intend is...

ns.seek(Math.floor(loader.scrub._x/336.6 * duration));

lukeldAuthor
Participant
July 13, 2009

Thank you so much! Solved the problem 100% Thank you!

Ned Murphy
Legend
July 13, 2009

You're welcome