auto refresh swf movie iusing action script 3












-1















I am creating a score board in flash, am fetching data from REST endpoints. Am able to read data once properly , after that same data repeating not able to read the update data. I tried with timer , could any one help me here



Thanks in advance



my code below



import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.text.TextField;
import flash.display.Graphics;

var white: Array = new Array();
var black: Array = new Array();
var red;
var striker;

var myTimer:Timer = new Timer(4000,100);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
function timerListener (e:TimerEvent):void{
trace("Timer is Triggered");
var urlLoader: URLLoader=null;

// load the JSON data from the URL
urlLoader = new URLLoader(new URLRequest("xxxxxxxxxxx"));
urlLoader.addEventListener(Event.COMPLETE, loadData);

// handle the load completion
function loadData(e: Event):void {
trace(e.target.data);

}
myTimer.start();
stop();









share|improve this question



























    -1















    I am creating a score board in flash, am fetching data from REST endpoints. Am able to read data once properly , after that same data repeating not able to read the update data. I tried with timer , could any one help me here



    Thanks in advance



    my code below



    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.text.TextField;
    import flash.display.Graphics;

    var white: Array = new Array();
    var black: Array = new Array();
    var red;
    var striker;

    var myTimer:Timer = new Timer(4000,100);
    myTimer.addEventListener(TimerEvent.TIMER, timerListener);
    function timerListener (e:TimerEvent):void{
    trace("Timer is Triggered");
    var urlLoader: URLLoader=null;

    // load the JSON data from the URL
    urlLoader = new URLLoader(new URLRequest("xxxxxxxxxxx"));
    urlLoader.addEventListener(Event.COMPLETE, loadData);

    // handle the load completion
    function loadData(e: Event):void {
    trace(e.target.data);

    }
    myTimer.start();
    stop();









    share|improve this question

























      -1












      -1








      -1








      I am creating a score board in flash, am fetching data from REST endpoints. Am able to read data once properly , after that same data repeating not able to read the update data. I tried with timer , could any one help me here



      Thanks in advance



      my code below



      import flash.net.URLLoader;
      import flash.net.URLRequest;
      import flash.events.Event;
      import flash.text.TextField;
      import flash.display.Graphics;

      var white: Array = new Array();
      var black: Array = new Array();
      var red;
      var striker;

      var myTimer:Timer = new Timer(4000,100);
      myTimer.addEventListener(TimerEvent.TIMER, timerListener);
      function timerListener (e:TimerEvent):void{
      trace("Timer is Triggered");
      var urlLoader: URLLoader=null;

      // load the JSON data from the URL
      urlLoader = new URLLoader(new URLRequest("xxxxxxxxxxx"));
      urlLoader.addEventListener(Event.COMPLETE, loadData);

      // handle the load completion
      function loadData(e: Event):void {
      trace(e.target.data);

      }
      myTimer.start();
      stop();









      share|improve this question














      I am creating a score board in flash, am fetching data from REST endpoints. Am able to read data once properly , after that same data repeating not able to read the update data. I tried with timer , could any one help me here



      Thanks in advance



      my code below



      import flash.net.URLLoader;
      import flash.net.URLRequest;
      import flash.events.Event;
      import flash.text.TextField;
      import flash.display.Graphics;

      var white: Array = new Array();
      var black: Array = new Array();
      var red;
      var striker;

      var myTimer:Timer = new Timer(4000,100);
      myTimer.addEventListener(TimerEvent.TIMER, timerListener);
      function timerListener (e:TimerEvent):void{
      trace("Timer is Triggered");
      var urlLoader: URLLoader=null;

      // load the JSON data from the URL
      urlLoader = new URLLoader(new URLRequest("xxxxxxxxxxx"));
      urlLoader.addEventListener(Event.COMPLETE, loadData);

      // handle the load completion
      function loadData(e: Event):void {
      trace(e.target.data);

      }
      myTimer.start();
      stop();






      actionscript-3 flash flash-cs5






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 24 '18 at 0:37









      AnandAnand

      743313




      743313
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Although I'm not sure what exactly is wrong with your code, there are things I wouldn't use in the project:




          1. Issuing HTTP requests to the same URL repeatedly on time basis, rather then waiting for each request to complete before sending another.


          2. Loader or URLLoader instances kept in local function variables. Normally, local function variables exist only as long as the function executes and their content (if not held by the application scope somehow) might be destroyed by Garbage Collector at literally ANY moment with no regard to your intent. UPD: There was an input that GC won't destroy an URLLoader while it has unfinished request to handle, still, having indestructible instances dangle somewhere you cannot reach them is not a good idea either.

          3. Functions defined inside other functions.


          With all that in mind the following should work fine:



          // Keep URLLoader instance within the scope.
          var L:URLLoader;

          // Issue the first request.
          loadNext();

          // This function issues the new request.
          function loadNext():void
          {
          var aReq:URLRequest = new URLRequest("xxxxxxx");

          L = new URLLoader(aReq);
          L.addEventListener(Event.COMPLETE, onData);

          // Error handling - a must have.
          L.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
          L.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError, false, 0, true);

          L.load();
          }

          // This function handles normal data processing.
          function onData(e:Event):void
          {
          // Sanity check. If event is triggered by anything
          // but the current URLLoader instance - do nothing.
          if (e.target != L) return;

          // Your data processing here.
          trace(L.data);

          // Clean-up the current request and schedule the next one.
          resetRequest();
          waitNext();
          }

          // This function handles all error events.
          function onError(e:Event):void
          {
          // Sanity check. If event is triggered by anyhting
          // but the current URLLoader instance - do nothing.
          if (e.target != L) return;

          // Report the error.
          trace("Oh, no:", e);

          // Clean-up the current request and schedule the next one.
          resetRequest();
          waitNext();
          }

          // This function destroys the current request.
          function resetRequest():void
          {
          // Sanity check. If there's no URLLoader instance - do nothing.
          if (!L) return;

          L.removeEventListener(Event.COMPLETE, onData);
          L = null;
          }

          // This function calls "loadNext" in 4 seconds.
          function waitNext():void
          {
          // Although the use of setTimeout counts as outdated,
          // it will still for our needs here.
          setTimeout(loadNext, 4000);
          }





          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454228%2fauto-refresh-swf-movie-iusing-action-script-3%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Although I'm not sure what exactly is wrong with your code, there are things I wouldn't use in the project:




            1. Issuing HTTP requests to the same URL repeatedly on time basis, rather then waiting for each request to complete before sending another.


            2. Loader or URLLoader instances kept in local function variables. Normally, local function variables exist only as long as the function executes and their content (if not held by the application scope somehow) might be destroyed by Garbage Collector at literally ANY moment with no regard to your intent. UPD: There was an input that GC won't destroy an URLLoader while it has unfinished request to handle, still, having indestructible instances dangle somewhere you cannot reach them is not a good idea either.

            3. Functions defined inside other functions.


            With all that in mind the following should work fine:



            // Keep URLLoader instance within the scope.
            var L:URLLoader;

            // Issue the first request.
            loadNext();

            // This function issues the new request.
            function loadNext():void
            {
            var aReq:URLRequest = new URLRequest("xxxxxxx");

            L = new URLLoader(aReq);
            L.addEventListener(Event.COMPLETE, onData);

            // Error handling - a must have.
            L.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
            L.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError, false, 0, true);

            L.load();
            }

            // This function handles normal data processing.
            function onData(e:Event):void
            {
            // Sanity check. If event is triggered by anything
            // but the current URLLoader instance - do nothing.
            if (e.target != L) return;

            // Your data processing here.
            trace(L.data);

            // Clean-up the current request and schedule the next one.
            resetRequest();
            waitNext();
            }

            // This function handles all error events.
            function onError(e:Event):void
            {
            // Sanity check. If event is triggered by anyhting
            // but the current URLLoader instance - do nothing.
            if (e.target != L) return;

            // Report the error.
            trace("Oh, no:", e);

            // Clean-up the current request and schedule the next one.
            resetRequest();
            waitNext();
            }

            // This function destroys the current request.
            function resetRequest():void
            {
            // Sanity check. If there's no URLLoader instance - do nothing.
            if (!L) return;

            L.removeEventListener(Event.COMPLETE, onData);
            L = null;
            }

            // This function calls "loadNext" in 4 seconds.
            function waitNext():void
            {
            // Although the use of setTimeout counts as outdated,
            // it will still for our needs here.
            setTimeout(loadNext, 4000);
            }





            share|improve this answer






























              0














              Although I'm not sure what exactly is wrong with your code, there are things I wouldn't use in the project:




              1. Issuing HTTP requests to the same URL repeatedly on time basis, rather then waiting for each request to complete before sending another.


              2. Loader or URLLoader instances kept in local function variables. Normally, local function variables exist only as long as the function executes and their content (if not held by the application scope somehow) might be destroyed by Garbage Collector at literally ANY moment with no regard to your intent. UPD: There was an input that GC won't destroy an URLLoader while it has unfinished request to handle, still, having indestructible instances dangle somewhere you cannot reach them is not a good idea either.

              3. Functions defined inside other functions.


              With all that in mind the following should work fine:



              // Keep URLLoader instance within the scope.
              var L:URLLoader;

              // Issue the first request.
              loadNext();

              // This function issues the new request.
              function loadNext():void
              {
              var aReq:URLRequest = new URLRequest("xxxxxxx");

              L = new URLLoader(aReq);
              L.addEventListener(Event.COMPLETE, onData);

              // Error handling - a must have.
              L.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
              L.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError, false, 0, true);

              L.load();
              }

              // This function handles normal data processing.
              function onData(e:Event):void
              {
              // Sanity check. If event is triggered by anything
              // but the current URLLoader instance - do nothing.
              if (e.target != L) return;

              // Your data processing here.
              trace(L.data);

              // Clean-up the current request and schedule the next one.
              resetRequest();
              waitNext();
              }

              // This function handles all error events.
              function onError(e:Event):void
              {
              // Sanity check. If event is triggered by anyhting
              // but the current URLLoader instance - do nothing.
              if (e.target != L) return;

              // Report the error.
              trace("Oh, no:", e);

              // Clean-up the current request and schedule the next one.
              resetRequest();
              waitNext();
              }

              // This function destroys the current request.
              function resetRequest():void
              {
              // Sanity check. If there's no URLLoader instance - do nothing.
              if (!L) return;

              L.removeEventListener(Event.COMPLETE, onData);
              L = null;
              }

              // This function calls "loadNext" in 4 seconds.
              function waitNext():void
              {
              // Although the use of setTimeout counts as outdated,
              // it will still for our needs here.
              setTimeout(loadNext, 4000);
              }





              share|improve this answer




























                0












                0








                0







                Although I'm not sure what exactly is wrong with your code, there are things I wouldn't use in the project:




                1. Issuing HTTP requests to the same URL repeatedly on time basis, rather then waiting for each request to complete before sending another.


                2. Loader or URLLoader instances kept in local function variables. Normally, local function variables exist only as long as the function executes and their content (if not held by the application scope somehow) might be destroyed by Garbage Collector at literally ANY moment with no regard to your intent. UPD: There was an input that GC won't destroy an URLLoader while it has unfinished request to handle, still, having indestructible instances dangle somewhere you cannot reach them is not a good idea either.

                3. Functions defined inside other functions.


                With all that in mind the following should work fine:



                // Keep URLLoader instance within the scope.
                var L:URLLoader;

                // Issue the first request.
                loadNext();

                // This function issues the new request.
                function loadNext():void
                {
                var aReq:URLRequest = new URLRequest("xxxxxxx");

                L = new URLLoader(aReq);
                L.addEventListener(Event.COMPLETE, onData);

                // Error handling - a must have.
                L.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
                L.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError, false, 0, true);

                L.load();
                }

                // This function handles normal data processing.
                function onData(e:Event):void
                {
                // Sanity check. If event is triggered by anything
                // but the current URLLoader instance - do nothing.
                if (e.target != L) return;

                // Your data processing here.
                trace(L.data);

                // Clean-up the current request and schedule the next one.
                resetRequest();
                waitNext();
                }

                // This function handles all error events.
                function onError(e:Event):void
                {
                // Sanity check. If event is triggered by anyhting
                // but the current URLLoader instance - do nothing.
                if (e.target != L) return;

                // Report the error.
                trace("Oh, no:", e);

                // Clean-up the current request and schedule the next one.
                resetRequest();
                waitNext();
                }

                // This function destroys the current request.
                function resetRequest():void
                {
                // Sanity check. If there's no URLLoader instance - do nothing.
                if (!L) return;

                L.removeEventListener(Event.COMPLETE, onData);
                L = null;
                }

                // This function calls "loadNext" in 4 seconds.
                function waitNext():void
                {
                // Although the use of setTimeout counts as outdated,
                // it will still for our needs here.
                setTimeout(loadNext, 4000);
                }





                share|improve this answer















                Although I'm not sure what exactly is wrong with your code, there are things I wouldn't use in the project:




                1. Issuing HTTP requests to the same URL repeatedly on time basis, rather then waiting for each request to complete before sending another.


                2. Loader or URLLoader instances kept in local function variables. Normally, local function variables exist only as long as the function executes and their content (if not held by the application scope somehow) might be destroyed by Garbage Collector at literally ANY moment with no regard to your intent. UPD: There was an input that GC won't destroy an URLLoader while it has unfinished request to handle, still, having indestructible instances dangle somewhere you cannot reach them is not a good idea either.

                3. Functions defined inside other functions.


                With all that in mind the following should work fine:



                // Keep URLLoader instance within the scope.
                var L:URLLoader;

                // Issue the first request.
                loadNext();

                // This function issues the new request.
                function loadNext():void
                {
                var aReq:URLRequest = new URLRequest("xxxxxxx");

                L = new URLLoader(aReq);
                L.addEventListener(Event.COMPLETE, onData);

                // Error handling - a must have.
                L.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
                L.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError, false, 0, true);

                L.load();
                }

                // This function handles normal data processing.
                function onData(e:Event):void
                {
                // Sanity check. If event is triggered by anything
                // but the current URLLoader instance - do nothing.
                if (e.target != L) return;

                // Your data processing here.
                trace(L.data);

                // Clean-up the current request and schedule the next one.
                resetRequest();
                waitNext();
                }

                // This function handles all error events.
                function onError(e:Event):void
                {
                // Sanity check. If event is triggered by anyhting
                // but the current URLLoader instance - do nothing.
                if (e.target != L) return;

                // Report the error.
                trace("Oh, no:", e);

                // Clean-up the current request and schedule the next one.
                resetRequest();
                waitNext();
                }

                // This function destroys the current request.
                function resetRequest():void
                {
                // Sanity check. If there's no URLLoader instance - do nothing.
                if (!L) return;

                L.removeEventListener(Event.COMPLETE, onData);
                L = null;
                }

                // This function calls "loadNext" in 4 seconds.
                function waitNext():void
                {
                // Although the use of setTimeout counts as outdated,
                // it will still for our needs here.
                setTimeout(loadNext, 4000);
                }






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 25 '18 at 21:59

























                answered Nov 24 '18 at 3:05









                OrganisOrganis

                5,0912610




                5,0912610
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454228%2fauto-refresh-swf-movie-iusing-action-script-3%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    Refactoring coordinates for Minecraft Pi buildings written in Python