Video Scrubber Modified

If you have been watching the Video Basics series at gotoAndLearn.com then you may have noticed some funky behavior with the scrubber. This problem is cause by using two intervals. A better way to do it is listed below. It creates an empty MovieClip and then uses it for an onEnterFrame implementation.

[as]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));
}[/as]


Quick and Dirty FLV

If you would like a step-by-step walk through of how to get an external FLV file to play in your Flash movies then please go to http://www.gotoandlearn.com. Here are the steps necessary in a very quick list:

  1. Goto the Library panel and click on the little button on the top right corner of the title bar.
  2. Choose “New Video” from the menu. This creates an embedded video object in your library.
  3. Drag this video object onto the stage and resize to the dimensions of your FLV.
  4. Give the video object an instance name. We’ll use “theVideo” for example.
  5. Create a blank layer named “Actions” and lock it.
  6. Highlight the first keyframe and open the actions panel.
  7. Paste in the following code:

[as]var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);
ns.play(“URL_OF_YOUR_FLV”);[/as]

  1. Test the movie and you should see the video playing.
  2. Smile :-)

Video Basics Tutorials

I have finally finished the last tutorial in the Video Basics series. Tutorials 1-8 teach you how to build a custom FLV video player from scratch which includes things like a scrubber bar, mute button, and a custom context menu. I’m planning on making an Advanced Video series which will cover more advanced and technical areas of using FLV files in Flash.

To the see the FLV tutorials you can go to http://www.gotoandlearn.com. These tutorials can also be seen at Creative Cow in the Flash forum where I’m a moderator.

Let me know if you find them helpful,
Lee


Welcome to The Flash Blog!

I know what you’re thinking, another Flash blog. Well why not? I mean the more information that is out there about this, often maddening, software the better. I’ll be posting as many bits of code, solutions to common annoyances, and tutorials as I possible can. This is where I will also be announcing new video tutorials that I’ll be placing on http://www.gotoandlearn.com.

Giddy up!
Lee