bcbirk100
01-04-2008, 11:57 PM
ok, so I created a video player in as3, and it works fine if i'm using null as my rtmp_host. but if i try to connect to my streaming server, it breaks, and acts as if it didn't load the class.
here's my code
public function VClass(target:MovieClip, rtmp_host:String, flv_name:String) {
//trace("VClass instantiated");
_video = new Video(550, 412);
_playbackTime = new TextField();
_playbackTime.y = 419;
_playbackTime.x = 425;
newFormat.font = "Verdana";
_playbackTime.embedFonts;
_playbackTime.text = "Loading";
_playbackTime.textColor = 0xFFFFFF;
_playbackTime.setTextFormat(newFormat);
_playbackTime.autoSize = TextFieldAutoSize.LEFT;
errorTxt = new TextField();
errorTxt.textColor = 0x00FF00;
errorTxt.x = 425;
errorTxt.y = 405;
errorTxt.autoSize = TextFieldAutoSize.LEFT;
errorTxt.text = "connecting...";
_duration = 0;
var connection:NetConnection = new NetConnection();
connection.addEventListener(SecurityErrorEvent.SEC URITY_ERROR, securityErrorHandler);
connection.addEventListener(NetStatusEvent.NET_STA TUS, netStatusHandler);
errorTxt.text = rtmp_host;
connection.connect(rtmp_host);
_stream = new NetStream(connection);
_stream.addEventListener(NetStatusEvent.NET_STATUS , netStatusHandler);
_stream.play(flv_name);
var client:Object = new Object();
client.onMetaData = onMetaData;
_stream.client = client;
_video.attachNetStream(_stream);
_video.smoothing = true;
target.addChild(_video);
target.addChild(_playbackTime);
target.addChild(errorTxt);
target.addEventListener(Event.ENTER_FRAME, onEnterFrame);
_scrubber = new VideoScrubber(target, _stream);
}// end of function
if i use it like this:
var vClass:VClass = new VClass(this, null, "test.flv");
it works fine, however when i change null and the flv name it breaks and it won't even show my textfields to show my error messages.
var vClass:VClass = new VClass(this, "rtmp://[myserver]/test", "test");
anybody see any errors in my script, or know why it would work with null but not with the rtmp server?
Thanks for the help.
here's my code
public function VClass(target:MovieClip, rtmp_host:String, flv_name:String) {
//trace("VClass instantiated");
_video = new Video(550, 412);
_playbackTime = new TextField();
_playbackTime.y = 419;
_playbackTime.x = 425;
newFormat.font = "Verdana";
_playbackTime.embedFonts;
_playbackTime.text = "Loading";
_playbackTime.textColor = 0xFFFFFF;
_playbackTime.setTextFormat(newFormat);
_playbackTime.autoSize = TextFieldAutoSize.LEFT;
errorTxt = new TextField();
errorTxt.textColor = 0x00FF00;
errorTxt.x = 425;
errorTxt.y = 405;
errorTxt.autoSize = TextFieldAutoSize.LEFT;
errorTxt.text = "connecting...";
_duration = 0;
var connection:NetConnection = new NetConnection();
connection.addEventListener(SecurityErrorEvent.SEC URITY_ERROR, securityErrorHandler);
connection.addEventListener(NetStatusEvent.NET_STA TUS, netStatusHandler);
errorTxt.text = rtmp_host;
connection.connect(rtmp_host);
_stream = new NetStream(connection);
_stream.addEventListener(NetStatusEvent.NET_STATUS , netStatusHandler);
_stream.play(flv_name);
var client:Object = new Object();
client.onMetaData = onMetaData;
_stream.client = client;
_video.attachNetStream(_stream);
_video.smoothing = true;
target.addChild(_video);
target.addChild(_playbackTime);
target.addChild(errorTxt);
target.addEventListener(Event.ENTER_FRAME, onEnterFrame);
_scrubber = new VideoScrubber(target, _stream);
}// end of function
if i use it like this:
var vClass:VClass = new VClass(this, null, "test.flv");
it works fine, however when i change null and the flv name it breaks and it won't even show my textfields to show my error messages.
var vClass:VClass = new VClass(this, "rtmp://[myserver]/test", "test");
anybody see any errors in my script, or know why it would work with null but not with the rtmp server?
Thanks for the help.