Hi all, 

I made a simple class that connects to my fms server. It's working and I can 
see the "connection ok" message from the handler. Depending on the handler 
result I want to interact with an stage element (to indicate this status) and 
this element should be dynamic passed to the class maybe, because in one 
project can be  textfield, in other a mc, in other a sound. Which would be a 
good way to manage this interaction?

thanks in advance

package {
 
 import flash.display.MovieClip;
 import flash.display.SpreadMethod;
 import flash.net.NetConnection;
 import flash.net.ObjectEncoding;
 import flash.display.Sprite;
 import flash.events.NetStatusEvent;

 public class conexaoFMS extends Sprite{
  
  var myConn:NetConnection;
  var urlConexao:String;
  var subDominio:String;
  
  //construtor
  public function conexaoFMS(urlServer:String, subDom:String) {
   
   NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
   myConn = new NetConnection();
   myConn.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

   this.urlConexao = urlServer;
   this.subDominio = subDom;
  
  }

  
  //tenta a conexao com a instancia
  public function conectar() {   
   var connString = urlConexao + "/" + subDominio;
   myConn.connect(connString);
  }  
  
  
  private function netStatusHandler(event:NetStatusEvent):void {
   
   trace ("      info.level:" + event.info.level);
   trace ("       info.code:" + event.info.code);
   trace ("info.description:" + event.info.description);
 
   if (event.info.application) {
    
    switch (event.info.code) {
     case "NetConnection.Connect.Success":
 
          trace("connection ok")
          break;

     case "NetStream.Play.StreamNotFound":

          trace("Stream not found: ");
          break;

    }
   }
  }
 }
}



then in flash I have a button on the stage and I use:

btConnect.addEventListener(MouseEvent.CLICK, onClick);

function onClick( event:MouseEvent):void {
 
 var xx:conexaoFMS;
 xx = new conexaoFMS("RTMP://123.123.123.123", "foo");
 xx.conectar();
 
}
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to