1 Reply Latest reply on Aug 23, 2006 12:29 PM by Newsgroup_User

    Problems with Shared Objects - WIERD (or i'm just plain o'l stupid)

    Level 7
      Using F8, AS2.0

      What I am trying to do is to store an array inside of a slot in a Local
      Shared Object.

      (snippet from function)

      // leaderboardShare is the Local Shared Object
      // the variable scores is passed through this function
      // if no array exists, create one
      if (this.leaderboardShare.data[this.userId] == null) {
      trace("{SharedLearning.setLeaderboardScore} no score data for this user
      exists, creating scores array");
      // create a new array to hold scores for this userId
      var myScores = new Array();
      myScores.push(score);
      this.leaderboardShare.data[this.userId] = myScores;
      // traces out the newly added score, (325)
      trace("{SharedLearning.setLeaderboardScore} scores in userId array: " +
      this.leaderboardShare.data[this.userId]);
      } else {
      trace("{SharedLearning.setLeaderboardScore} score data exists, adding
      current score to array ");
      // traces out existing data in userId slot (325)
      trace("{SharedLearning.setLeaderboardScore} scores in userId array: " +
      this.leaderboardShare.data[this.userId]);
      // traces out Number
      trace("score is type: " + typeof(score));
      // temp array to hold data from existing LSO scores
      var myScores:Array = this.leaderboardShare.data[this.userId];
      // traces 325
      trace("myScores (before): " + myScores);
      // temp variable to hold latest score passed through (dont' really need
      this)
      var newScore:Number = score;
      // add latest score to current score array
      myScores.push(newScore);
      // TRACES 325, NaN !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      trace("myScores (after): " + myScores);
      // overwrite existing scores array in LSO with new set of scores
      this.leaderboardShare.data[this.userId] = myScores;
      }

      I know I can do this with any other object, what gives? why would the LSO
      even care what i'm passing to it. Who cares that it's not a number, the
      array doesn't care what you stick into it.

      I'm truly confused.

      Any help will help me drink less tonight after i'm finished ;)