0 Replies Latest reply on Sep 30, 2008 5:42 AM by uomodicuore2

    Shared Object problem

    uomodicuore2
      Hi all,
      I made a slot machine. I have to limit the quantities for each payout, and generate a report of how many of each were paid out. For this, I created a local shared object that stores each individual spin and also totals for each payout.

      The problem: I want to use another flash movie (which accesses the same shared object) to display the data in report format. If I spin, and then close the movie, and open the other one, there's nothing. What I have to do is spin and close the movie three times before anything shows up in the other movie. The problem is that I have several prizes unaccounted for.

      Any advice would be greatly appreciated.

      Code is attached.
      Attach Code

      stop();
      //Make variables
      var prize1, prize2, prize3;
      var qty1, qty2, qty3;
      var used1, used2, used3;
      //Done making variables

      //Load the external data
      var prizeimport=new LoadVars();
      prizeimport.load('promovgmprizes.txt');
      prizeimport.onLoad=function(){
      prize1=prizeimport.var1;
      prize2=prizeimport.var2;
      prize3=prizeimport.var3;
      qty1=prizeimport.var1a;
      qty2=prizeimport.var2a;
      qty3=prizeimport.var3a;
      used1=0;
      used2=0;
      used3=0;

      //show paytable values
      for(b=1;b<4;b++){
      eval("pay"+ ).text=eval("prize"+);
      }//done showing paytable values
      }//done loading external data

      //populate used variables
      if(used1==null){
      used1=0;
      trace(used1);

      }//done with if statement
      if(used2==null){
      used2=0;
      trace(used2);

      }//done with if statement
      if(used3==null){
      used3=0;
      trace(used3);
      }//done with if statement

      //done populating used variables

      //start up the local shared object
      mySO=SharedObject.getLocal("spins","/");
      if(mySO.data.spinCount==null){
      mySO.data.spinCount="Spin Results";
      }
      if(mySO.data.prizeTotals==null){
      mySO.data.prizeTotals="Prizes Used";
      }
      mySO.flush();
      //done starting up the local shared object

      //Store data locally

      function sendDataToLocal(spinResult){
      mySO=SharedObject.getLocal("spins","/");
      inputOut=spinResult;
      theTime = new Date();
      spinTime= (theTime.getYear()+1900)+" . "+(theTime.getMonth()+1)+" . "+theTime.getDate()+", "+theTime.getHours()+":"+theTime.getMinutes();
      mySO.data.spinCount+="\n"+spinTime+": "+inputOut+"\n----------------------";
      mytempPrize=prize1+" Used= "+used1+"\n"+prize2+" Used= "+used2+"\n"+prize3+" Used= "+used3+"\nTotal Spins: "+(used1+used2+used3+"\n";
      mySO.data.prizeTotals=mytempPrize;
      trace(mytempPrize);
      mySO.flush();

      inputOut="";
      }
      //Done storing data locally

      function winnerReels(){
      var whichReel= Math.ceil(Math.random()*3);
      if(eval("qty"+[whichReel])>0){
      showPrize(whichReel);
      }//end if statement
      else {winText.text="No Prize! Try Again!";}
      }//end winnerReels function

      function showPrize(whichPrize){
      eval("winner"+[whichPrize]).gotoAndPlay(2);
      if(whichPrize==1){qty1--;used1++; winText.text="You won "+prize1+ " "+qty1;sendDataToLocal(prize1);};
      if(whichPrize==2){qty2--;used2++; winText.text="You won "+prize2+ " "+qty2;sendDataToLocal(prize2);};
      if(whichPrize==3){qty3--;used3++; winText.text="You won "+prize3+ " "+qty3;sendDataToLocal(prize3);};
      }//end showPrize function