PDA

View Full Version : Problem using classes to control FMS video stream


aemdliz
02-04-2009, 04:45 PM
I have a video file I'm pulling from a FMS. I have code in the following files: T_Video_02.as & NavButtons.as. I want to put all my button control code in NavButtons.as.

Here is my T_Video_02.as code ( I started with the pauseVideo function and it works works here but when I comment it out and try to use the pauseVideo function in the NavButton.as I get a "1120: Access of undefined property pauseVideo" error message.)


package {
import flash.display.MovieClip;
import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.net.NetStream;
import flash.media.Video;
import flash.events.MouseEvent;


public class T_Video_02 extends MovieClip {
var nc:NetConnection;
var stream:NetStream;
var playStream:NetStream;
var video:Video;

function T_Video_02() {
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect("rtmp://www.ibdunn.com/video");
}
function netStatusHandler(event:NetStatusEvent):void {
trace("connected is: " + nc.connected);
trace("event.info.level: " + event.info.level);
trace("event.ifo.code: " + event.info.code);

switch (event.info.code) {
case "NetConnection.Connect.Success" :
trace("Congratulations! you're connected");
playVideo(nc);
break;
case "NetConnection.Connect.Failed" :
case "NetConnection.Connect.Rejected" :
trace("Oops! teh connection was rejected");
break;
case "NetStream.Play.StreamNotFound" :
trace("The server cound not find the stream you specified");
break;
case "NetStream.Publish.BadName" :
trace("The stream name is alrready used");
break;
}
}
function playVideo(nc:NetConnection):void {
stream = new NetStream(nc);
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stream.client = new CustomerClient();
video = new Video();
video.attachNetStream(stream);
stream.play("vultures123456");
addChild(video);
control_mc.pause_mc.addEventListener(MouseEvent.CL ICK, pauseVideo);
control_mc.pause_mc.useHandCursor = true;
control_mc.pause_mc.buttonMode = true;

/*function pauseVideo(e:MouseEvent):void{
stream.pause();
}*/
}
}
}

class CustomerClient {
public function onMetaData(info:Object):void {
trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
}
public function onPlayStatus(info:Object):void {
trace("handling playstatus here");
}
}


Here is my NavButton.as code: Can anyone help me understand what I doing wrong?

package
{
import flash.display.MovieClip;
public class NavButton_02 extends MovieClip
{
public function NavButton_02()
{
trace("NavButton_02 init");
function pauseVideo(e:MouseEvent):void {
stream.pause();
}
}
}
}

ASWC
02-04-2009, 04:50 PM
You have your pauseVideo function inside the constructor therefore it has only a local scope and cannot be seen and called from outside the constructor.