server help - new to this
cane2980 Jul 17, 2011 12:13 PMHey all total newb to as3 and FMS so please be kind... BTW I'm one of those designer people trying to learn this and am by no means a programmer or networking guru.
Ok here it is. I'm running FMS 4 Dev on my win XP SP3 machine, also running flash cs5 professional on same machine. I get the server admin screen to come up and it says it's running. I'm using a tut book on FMS and trying to run the first script in the book. It's long but I'll add the script at the bottom so you can see what i'm doing. In the server app folder I placed another folder called vid2 with nothing in it just like the book told me to do. I wrote the script line for line out of the book. When I test my movie it lays out my video window and buttons. It diplays my ugly mug on the screen. when I press the record button it does nothing. when i press the stop button the output window shows me an error of "#1009 can't access properties or methods of a null object". I assume that this is telling me I do not have a net connection.
First of all please tell me what is wrong if you can. Second answer these questions to me if possible. 1) when I types in the example it had an IP address in the code.How do I know the correct IP addy to my dev server? If I'm doing development and testing on the same machine do I even need to know this? 2) How will what I'm doing now differ from leasing space from an FMS provider?
Thanks for any help you my have...
the script:
package{
import fl.controls.Button;
import fl.controls.TextInput;
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.NetStatusEvent;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.media.Camera;
import flash.media.Microphone;
import flash.media.Video;
public class MinRecord2 extends Sprite{
private var nc:NetConnection;
private var ns:NetStream;
private var rtmpNow:String;
private var msg:Boolean;
private var cam:Camera;
private var mic:Microphone;
private var vid1:Video;
private var recordBtn:Button;
private var stopBtn:Button;
private var textInput:TextInput;
//Constructor
function MinRecord2 (){
nc=new NetConnection();
nc.addEventListener (NetStatusEvent.NET_STATUS,checkConnect);
rtmpNow="rtmp://192.168.0.1/vid2/recordings";
nc.connect (rtmpNow);
addMedia ();
addUI ();
recordBtn.addEventListener(MouseEvent.MOUSE_DOWN, startRecord);
stopBtn.addEventListener(MouseEvent.MOUSE_DOWN, stopRecord);
}
private function addMedia ():void{
cam=Camera.getCamera();
cam.setMode (240,180,24);
cam.setQuality (0,90);
mic=Microphone.getMicrophone();
vid1=new Video(cam.width,cam.height);
vid1.attachCamera (cam);
addChild (vid1);
vid1.x=100;
vid1.y=50;
}
private function addUI ():void{
recordBtn=new Button();
recordBtn.label="Record";
recordBtn.x=100;
recordBtn.y=50+(cam.height) +5;
recordBtn.width=70;
addChild (recordBtn);
stopBtn=new Button();
stopBtn.label="Stop Record";
stopBtn.x=recordBtn.x+85;
stopBtn.y=recordBtn.y;
stopBtn.width=75;
addChild (stopBtn);
textInput=new TextInput();
textInput.x=recordBtn.x;
textInput.y=recordBtn.y + 30;
addChild (textInput);
}
private function checkConnect (event:NetStatusEvent):void{
msg=(event.info.code=="NetConnection.Connect.Success");
if (msg){
ns = new NetStream(nc);
}
}
private function startRecord (event:Event):void{
if (ns)
{
recordBtn.label="Recording";
ns.attachAudio (mic);
ns.attachCamera (cam);
ns.publish (textInput.text,"record");
}
}
private function stopRecord (e:Event):void{
recordBtn.label="Record";
ns.close ();
}
}
}

