All this code works properly, however when I include the part which controls the video resize metadata the scrubber stops working… (see the section between the “>>> <<<”). Any ideas as to what is conflicting between the script? Thanks in advance.
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.setBufferTime(2);
ns.onStatus = function(info) {
if (info.code == "NetStream.Buffer.Full") {
bufferClip._visible = false;
}
if (info.code == "NetStream.Buffer.Empty") {
bufferClip._visible = true;
}
if (info.code == "NetStream.Play.Stop") {
_root.videoSliderMc.newY = Stage.height;
}
};
my_video.attachVideo(ns);
var videoInterval = setInterval(videoStatus, 100);
var amountLoaded:Number;
var duration:Number;
ns["onMetaData"] = function (obj) {
duration = obj.duration;
};
my_video._x = 30;
my_video._y = 78;
my_video._width = 640;
my_video._height = 360;
var vidW:Number;
var vidH:Number;
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ns["onMetaData"] = function (vidSize) {
// Retrieve the width/height from the MetaData
// set the var we declared earlier to these numbers
vidW = vidSize.width;
vidH = vidSize.height;
trace("Video Width = "+vidW+" "+" Video Height = "+vidH);
// Based on the width/height from the MetaData
// set the width/height of your video object instance
my_video._width = vidW;
my_video._height = vidH;
// reposition it also based on width/height
my_video._x = 30+(640-vidW)/2;
my_video._y = 78+(360-vidH)/2;
};
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
function videoStatus() {
amountLoaded = ns.bytesLoaded/ns.bytesTotal;
loaderMC.loadbar._width = amountLoaded*640;
loaderMC.scrub._x = ns.time/duration*635;
}
var scrubInterval;
_root.videoSliderMc.loaderMC.scrub.onPress = function() {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit, 10);
this.startDrag(false,0,this._y,635,this._y);
};
loaderMC.scrub.onRelease = loaderMC.scrub.onReleaseOutside=function () {
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus, 100);
this.stopDrag();
};
loaderMC.scrub.onRollOver = function() {
onEnterFrame = function () {
if (_alpha<100) {
_alpha += 10;
}
};
};
function scrubit() {
ns.seek(Math.floor((loaderMC.scrub._x/640)*duration));
}