Hi list...
I've written a singleton that should load in videos on demand, but it
plays the video twice, once only audio, and the second, a couple of
milliseconds later, both audio and video. Components on the stage call
loadVideo, and through debugging, I know that call is only fired once,
therefore, I can't figure out why the video runs twice. Also, I don't
get what the difference is between an FLVplayback component and a Video
item in the library. And, is there a method that commences loading of a
video? And also, a property that shows elapsed time? The documentation
just isn't clear to me.
Thanks,
- Michael M.
import flash.external.*;
import flash.geom.Transform;
import flash.geom.ColorTransform;
class welcomeWebpage {
// class properties
///////////////////////////////////////////////////////////////
public var nc:NetConnection;
public var ns:NetStream;
public var ui:MovieClip;
public var intervalIDs:Object;
public static var inst:welcomeWebpage = undefined;
// class methods
//////////////////////////////////////////////////////////////////
private function welcomeWebpage() {
// singleton pattern
}
public static function getInstance():welcomeWebpage {
if (inst == undefined) {
inst = new welcomeWebpage();
}
return inst;
}
public function init():Void {
// init class properties...
intervalIDs = {loader:new Number(), player:new
Number()};
ui = _root.ui;
ui.vidDisplay.stop();
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
}
// video related methods
////////////////////////////////////////////////////////////
public function loadVideo(theVid, callingLink) {
ui.vidDisplay.gotoAndStop(2);
ns.play(theVid);
intervalIDs.loader = setInterval(this, "loadProgress",
100, theVid);
}
public function loadProgress(nameOfVid):Void {
if ((ns.bytesLoaded / ns.bytesTotal) == 1) {
// finished loading: clear interval, play video
this.playVideo(nameOfVid);
clearInterval(this.intervalIDs.loader);
} else {
// not completely loaded in yet
trace(Math.round((ns.bytesLoaded /
ns.bytesTotal) * 100) + ": pct loaded of " + nameOfVid);
}
}
public function playVideo(theVid):Void {
// done loading, now play...
ui.vidDisplay.theScreen.contentPath = theVid;
//intervalIDs.player = setInterval(this, "playProgress",
100, theVid);
}
public function playProgress(nameOfVid):Void {
trace(ui.vidDisplay.theScreen.contentPath + " " +
ns.time);
}
}
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com