NetStream is rejecting camera, but video object can preview it

Hello,

I am kinda new in Flash, but I was using Action Script before in other programs.
I am developing now Adobe Flash Professional CS5.5, and working with Adobe Media Server 4.
I am writing a code that will stream camera to server live.
Here is my code:


var cam1:Camera = Camera.getCamera(); 

var nc:NetConnection = new NetConnection();
nc.connect("rtmp://<link to media server>");
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);


function netStatusHandler(event:NetStatusEvent):void{
    if (event.info.code == "NetConnection.Connect.Success")
    {
    label10.text = 'Connected';
    var ns:NetStream = new NetStream(nc);
    ns.attachCamera(cam1);
    ns.publish("myCamera","live");    
    
    }

When I run this application camera light that signal that camera is used turn on, but in few seconds it turn off…
So that means it get disconnected from streamer.

What might cause this?

When I add code to attach it to video:


var camera1:Camera = Camera.getCamera();
var video1:Video = new Video();
video1.attachCamera(camera1);
addChild(video1);

Camera light is on and it’s shown inside application.
So Flash is accepting my camera, it is working okay, but NetStream is rejecting it.
I don’t know why…
Also, when I open Adobe Media Server start up page, it has two windows broadcast and watch, and when I publish/watch here it is working okay… Even from my pc when I run this file, not from online server, it is working okay.

Is there any open source/sample/tutorial file that has this script in it and that is tested and working so I can test it on my Flash develop program and my pc?

Thank you!