5 Replies Latest reply on Jul 5, 2013 4:45 PM by Ned Murphy

    Test Movie, with webservice

    Paulcardo Level 1

      Hi,

       

      Im doing a game that shows numbers based on a webservice call, it calls the service every 10 seconds, and the numbers change after a while.

       

      I can see the numbers change when I select:  Test Movie in Browser.   It works fine.

       

      But the numbers never change when is :  Test Movie in Flash Professional

      When I do Test Movie in Flash Professional, it call the webservice, but the answer is always the same, but when test the service in a browser the answer/numbers have changed.

       

       

      Please help, I have tried changing settings in the Publish, the best i got was on Debug, It gets the first call a fresh answer from the service, but the nexts call the answer does not change.

      Im just starting with Flas CC and AS3. I have done other games with AS2 and never saw this problem.

       

      I can share the .fla and .as     if nedded

       

      Thanks

       

      Paul

        • 1. Re: Test Movie, with webservice
          Ned Murphy Adobe Community Professional & MVP

          What does the code for the call to the service look like?

          • 2. Re: Test Movie, with webservice
            Paulcardo Level 1

            Here the service and call code:

            http://sweepstakes.clickbit.net/theThingServerSide/theThing.theThingMethods.svc/ajaxendpoi nt/getResult?agentID=86

             

             




            this.gWebServiceURL = 'http://sweepstakes.clickbit.net';



            this.gAgentId = '86';


             











            function doActionGetResult():void {



            trace("- --------------------------- -");



            trace("-      doActionGetResult      -");



            trace("- --------------------------- -");



            var xmlDocResult:URLLoader = new URLLoader();



            xmlDocResult.addEventListener(Event.COMPLETE, Result_doActionGetResult);



            xmlDocResult.addEventListener( IOErrorEvent.IO_ERROR, Error_doActionGetResult );



            xmlDocResult.addEventListener( SecurityErrorEvent.SECURITY_ERROR, Error_doActionGetResult );



            trace(this.gWebServiceURL + "/theThingServerSide/theThing.theThingMethods.svc/ajaxendpoint/getResult?agentID=" + this.gAgentId);



            var request:URLRequest = new URLRequest(this.gWebServiceURL + "/theThingServerSide/theThing.theThingMethods.svc/ajaxendpoint/getResult?agentID=" + this.gAgentId);



            xmlDocResult.load(request);


            };

             

             



            function Error_doActionGetResult( error:ErrorEvent ):void


            {



            trace('ERROR = doActionGetResult');  


            }

             

             



            function Result_doActionGetResult(evnt:Event):void {



            var loader:URLLoader = URLLoader(evnt.target);



            var XMLresult:XML = new XML();



            XMLresult.ignoreWhitespace = true;



            XMLresult = XML(loader.data);



            trace("doActionGetResult << " + XMLresult.toString());



            var theStatus;



            var arrayTemp = new Array();



            var numDelay;

             

             

            blah...blah...

            }

            • 3. Re: Test Movie, with webservice
              Ned Murphy Adobe Community Professional & MVP

              Try adding a randomly generated number to the end of the call as another url variable and see if that helps....

               

              var request:URLRequest = new URLRequest(this.gWebServiceURL + "/theThingServerSide/theThing.theThingMethods.svc/ajaxendpoint/getResult?agentID=" + this.gAgentId + "&randNum=" + Math.random());

              • 4. Re: Test Movie, with webservice
                Paulcardo Level 1

                wow!, that worked. Thanks!

                Looking old... old code AS2, it has an extra parameter random, I thinked it was for the server,

                never thinked it was for Flash because in more actual AS2 code it did not need the extra parameter random.

                • 5. Re: Test Movie, with webservice
                  Ned Murphy Adobe Community Professional & MVP

                  What the random variable does is it forces the url request to be unique each time which drives the processing to look to the server to fulfill the request rather than the cache.

                  1 person found this helpful