0 Replies Latest reply on Jan 3, 2011 8:35 AM by juresti

    AS2 function code talking to LMS

    juresti Level 1

      I'm confused if anyone can make sense of this let me know or see anything wrong. Thanks you.

       

      These are the functions in the first frame of the main timeline:

       

      var section_completions:Array = [0,0,0];  //0 means incomplete

       

      function SectionCompletion() {
               section_completions = scorm.get("cmi.suspend_data").split(",");
               if (section_completions.toString() == "1,1,1") {
                       //this.attachMovie("test", "newInstanceName", 1, {_x: 50, _y: 100});
                       gotoAndStop("Level1Completed");

              }
               else {
               };

      }

      function saveBookmark(loc:String) {

       

         scorm.set("cmi.core.lesson_location", loc);

       

         scorm.save();

       

      }

      function getBookmark():String {

       

        return scorm.get("cmi.core.lesson_location");

       

      }

      var bookmark:String = getBookmark();

       

      //waiter, there's a Q in my bookmark!
      if(bookmark.indexOf("Q") !== -1 && bookmark !== undefined){
          //add the underscore after the Q to match filename
          bookmark = bookmark.split("Q").join("Q_");
          swfURL = bookmark +".swf";
          trace(swfURL);

      }

      startPreload(swfURL);

       

      I need the suspend_data to remain after exiting, if it is "0,1,0" I
      want it to remain "0,1,0" upon returning or if it is "1,1,1" which
      means the 3 sections are complete I want it to remain "1,1,1"

      Does this code look correct? Any help is appreciated.

       

       

      In my online module I have this code at the end of each section, there are 3, it sets [0], [1], and [2]
      to 1:

       

      section_completions[1] = 1;

      scorm.set("cmi.suspend_data",section_completions.toString());
      scorm.save ();

      section_completions = scorm.get("cmi.suspend_data").split(",");

       

      SectionCompletion();