title: How can I Call a function within a function using action script 3.0
body: <p><strong>How can i call function in another function using action script 3.0
  Here I am Using WSDL Web service and getting data in my data grid. i want to put this data into my database table.</strong> </p>
  
  <p>I am calling Following function on Button click event which is associated to WebService .</p>
  
  <pre><code>private function Login():void {
                  // Get Data from WebService and fill datagrid when you fist invoke the application
                  SignIn1Result2.token = vtrServices.SignIn1(txtUserName.text, txtPassword.text);
                  stmt.sqlConnection = this.isDbConnected(conn);
                  func:addEventListener(SQLEvent.OPEN,insertContact);
  
                   /* insertContact(SignIn1Result2.lastResult.UserId,SignIn1Result2.lastResult.UserName,SignIn1Result2.lastResult.ContactName,SignIn1Result2.lastResult.Password,SignIn1Result2.lastResult.Salt); */
                  }
  </code></pre>
  
  <p><strong>And my WebService Definition is</strong></p>
  
  <pre><code>  &lt;fx:Declarations&gt;
              &lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;
              &lt;mx:WebService 
                  id="ws" 
                  wsdl="http://localhost:2690/vtrServices.asmx?wsdl"&gt; 
                  &lt;mx:operation 
                      name="GetEmployees" 
                      resultFormat="object"
                      result="Login()"
                      /&gt;
  
              &lt;/mx:WebService&gt;
              &lt;vtrservices:VtrServices id="vtrServices"
                                       fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
                                       showBusyCursor="true"/&gt;
              &lt;s:CallResponder id="SignIn1Result2"/&gt;
   &lt;/fx:Declarations&gt;
  </code></pre>
  
  <p>My controls </p>
  
  <pre><code>&lt;mx:Panel x="41.5" y="66" width="714.5" height="237" layout="absolute" title="ASP.NET WebService + Flex Demonstration"&gt;
          &lt;mx:HBox height="95%" width="95%" horizontalCenter="0" verticalCenter="0"&gt;
              &lt;mx:DataGrid id="datagrid" width="499" height="100%"
                           dataProvider="{SignIn1Result2.lastResult}"&gt;
                  &lt;mx:columns&gt;
                      &lt;mx:DataGridColumn headerText="User Id" dataField="UserId"/&gt;
                      &lt;mx:DataGridColumn headerText="UserName" dataField="UserName"/&gt;
                      &lt;mx:DataGridColumn headerText="ContactName" dataField="ContactName"/&gt;
                      &lt;mx:DataGridColumn headerText="Password" dataField="Password"/&gt;
                      &lt;mx:DataGridColumn headerText="Salt" dataField="Salt"/&gt;
                  &lt;/mx:columns&gt;
              &lt;/mx:DataGrid&gt;
  
              &lt;mx:Form x="608" y="74" width="100%" height="100%" borderStyle="solid" id="UserLogin"&gt;
  
                  &lt;mx:FormItem label="UserName"&gt;
                      &lt;mx:TextInput width="106" id="txtUserName"/&gt;
                  &lt;/mx:FormItem&gt;
  
                  &lt;mx:FormItem label="Password"&gt;
                      &lt;mx:TextInput width="106" 
                                    displayAsPassword="true"
                                    id="txtPassword"/&gt;
                  &lt;/mx:FormItem&gt;
  
                  &lt;mx:FormItem width="156" horizontalAlign="right"&gt;
                      &lt;mx:Button label="Login" id="btnLogin" click="Login();"/&gt;
                  &lt;/mx:FormItem&gt;
  
              &lt;/mx:Form&gt;
          &lt;/mx:HBox&gt;
      &lt;/mx:Panel&gt;
  </code></pre>
  
  <p><strong>here is the following function which should be called after success of Login() funtion or i can say within the Login() Function</strong></p>
  
  <pre><code>private function insertContact(UserId:String, UserName:String,ContactName:String, Password:String, Salt:String):void
              {
                  stmt.sqlConnection = this.isDbConnected(conn);
                  stmt.text = "INSERT INTO TblUsers (UserId, UserName, ContactName ,Password, Salt) VALUES('"+SignIn1Result2.lastResult.UserId+"','"+SignIn1Result2.lastResult.UserName+"','"+SignIn1Result2.lastResult.ContactName+"','"+SignIn1Result2.lastResult.Password+"','"+SignIn1Result2.lastResult.Salt+"');";  
                  Alert.show("Contact Has been Saved");
                  stmt.execute();
              }
  </code></pre>
  
  <p>I have Binded the following </p>
  
  <pre><code>[Bindable]
          public var conn:SQLConnection = new SQLConnection();
  
  
          [Bindable]
          private var stmt:SQLStatement = new SQLStatement();
  
          // ArrayCollection used as a data provider for the datagrid. It has to be bindable so that data in datagrid changes automatically when we change the ArrayCollection
  
          [Bindable]
          private var contactList:ArrayCollection = new ArrayCollection(); 
  </code></pre>
  
  <p><strong>InsertContact() Is the function that i want to call within the Login() function execution success</strong> </p>