2 Replies Latest reply on Sep 17, 2010 5:41 PM by Mark Robbins 312

    Problems calling a function from another function

    djh88ukwb Level 1

      Hello all.

       

      I am trying to create a function that will loop a few other function.

       

      Basically the main function is this

       

                          private function publish(event:MouseEvent):void
                          {
                              if (doPublish.label == 'Publish')
                              {
                                  // create a new NetStream object for video publishing
                                  nsPublish = new NetStream(nc);
                                 
                                  nsPublish.addEventListener(NetStatusEvent.NET_STATUS, nsPublishOnStatus);
                                 
                                  // set the buffer time to zero since it is chat
                                  nsPublish.bufferTime = 0;
                                 
                                  // publish the stream by name
                                  nsPublish.publish(publishName.text);
                                 
                                  // add custom metadata to the stream
                                  var metaData:Object = new Object();
                                  metaData["description"] = "Chat using VideoChat example."
                                  nsPublish.send("@setDataFrame", "onMetaData", metaData);
                                 
                                  // attach the camera and microphone to the server
                                  nsPublish.attachCamera(camera);
                                  nsPublish.attachAudio(microphone);
                                 
                                  doPublish.label = 'Stop';
                              }
                              else
                              {
                                  // here we are shutting down the connection to the server
                                  nsPublish.attachCamera(null);
                                  nsPublish.attachAudio(null);
                                  nsPublish.publish("null");
                                  nsPublish.close();
                                 
                                  doPublish.label = 'Publish';
                              }
                          }

       

       

      I am then trying to call that function like this

       

                  protected function startloop():void {
                      publish(event);
                  }

       

      But i get the error Access of undefined property event.

       

      Any ideas on how i can call this function ?  I need to call it as part of a loop against a timer..

       

      Thanks in advance