2 Replies Latest reply on Oct 28, 2009 4:50 PM by oldMster

    Dynamic  <mx:request> entries

    alba1010101

      Is there anyway to create dynamic parameters and load these to mx:request within HTTPService. Using an Object is OK. But how to add dynamic elements to the object ?

       

      E.G

       

      var myObject:Object = new Object;

       

      for (var i:Number = 0; i< 100; i++)

      {

          myObject.dynamicVariablename = i + " yeah this works";

      }

       

      var myService:HTTPService = new HTTPService( "/some_url" );
      var asTkn:AsycToken = myService.send( myObject);

        • 1. Re: Dynamic  <mx:request> entries
          PeakDigital Level 1

          I think you need to just add this line:

           

          myService.request=myObject;

           

          before you send() the service.

          • 2. Re: Dynamic  <mx:request> entries
            oldMster Level 3

            I don't really understand what you are trying to do.  Do you want to add unknown at compile POST/GET values?  When I need to do that, I use an XML document for the value:

            var params:Object = new Object();

            var myXML:XML = <Stuff/>;

            var moreXML:XML;

             

            //any fixed (known at Compile time) name value pairs

             

            params.FixedItem1=value1;

            params.FixedItem2=value2;

             

            //then I put all the 'dynamic' name value pairs into an XML structure

             

            for (var i:Number = 0; i< 100; i++)

            {

                 moreXML = <Element/>;

                 moreXML.Name = "MyDynamicinstance";

                 moreXML.Value = i;

                 myXML.appendChild(moreXML);

            }

            //then make the XML part of the parameters object

             

            params.DynamicStuff = myXML;

             

            // and send it

            myService.send(params);

             

             

            Mark