1 Reply Latest reply on Aug 9, 2008 6:07 AM by Newsgroup_User

    Doing a LoadVars onEnterFrame

    gigasaurus Level 1
      I have a frame in my main timeline where I do 2 LoadVars to send and receive variables from a page. Right now this is initiated by clicking a button. I now need this to occur onEnterFrame (rather than by pushing a button). I am using AS2.

      Can someone please tell me how to modify my code?
        • 1. Re: Doing a LoadVars onEnterFrame
          Level 7
          >>function sendRecords():Void {
          records.sendAndLoad("records.php?thisID=999999", recordsSent);
          records_message.text = "Sending";
          };

          First off, I'd say you may want to change this so you can use POST, instead
          of having to use GET:

          function sendRecords():Void {
          records.thisID = 999999;
          records.sendAndLoad("records.php", recordsSent);
          records_message.text = "Sending";
          };

          To call it from an enterFrame, I'd just use a flag variable so you only call
          it one time. Something like so:


          var records:LoadVars = new LoadVars();
          var recordsSent:LoadVars = new LoadVars();
          var didSend = false;

          function sendRecords():Void {
          records.thisID = 999999;
          records.sendAndLoad("records.php", recordsSent);
          records_message.text = "Sending";
          };

          recordsSent.onLoad = function(success:Boolean) {
          if (success) {
          records_message.text = this.myReceivedVariable;
          }
          };

          this.onEnterFrame = function(){
          if(!didSend){
          didSend = true;
          sendRecords();
          }
          }

          --
          Dave -
          www.offroadfire.com
          Head Developer
          http://www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/