3 Replies Latest reply on Nov 6, 2007 8:17 AM by injpix

    Please help on how to use variables inside a method call

    carlos421
      Hello guys,

      How's it goin?

      Pardon me if you find my question silly, but I am relatively new in ActionScript 2.0 programming.

      I have here a simple problem. It seems I can't use a variable inside a method call of an object. Here's the code. Please note of the authParams string variable below.

      import AkamaiConnection;
      import mx.services.WebService;
      var GeneratedToken:String;
      var authParams:String;

      // Create a Web Service object
      var TokGenService:WebService = new WebService(" http://webservice.asmx?wsdl");
      // Call the web service method
      var myToken:Object = TokGenService.GenerateToken();

      // Create an AkamaiConnection object
      var connection:AkamaiConnection = new AkamaiConnection();
      connection.addEventListener("onConnect", this);
      connection.addEventListener("onError", this);

      // If you get a result from the web service, save the result in a variable
      myToken.onResult = function(result)
      {
      // If you get a result from the web service, save the result in a variable
      myToken.onResult = function(result)
      {
      GeneratedToken = result;
      authParams = GeneratedToken + "&aifp=v001&slist=37414/test/Streaming/";

      //Call the Connect method of the AkamaiConnection class
      connection.connect("cp37414.edgefcs.net/ondemand",true,true,5,true,false,"443","rtmpt", authParams);

      };

      But then, if I use a hard-coded string value in lieu of the variable, the method call works!

      connection.connect("cp37414.edgefcs.net/ondemand",true,true,5,true,false,"443","rtmpt", "testStringvalue");

      I don't know what I'm missing or what I'm doing wrong... Can somebody help me please? I am using a 30-day trial version of Adobe Flash CS3. Also, when I Trace output the variables, the values are there. It just that they can't be read or recognize inside the method call. Is this a ActionScript limitation?

      Thanks so much in advance!