Not signed in (Sign In)

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthormark.b
    • CommentTimeMay 5th 2008 edited
     
    I've tried every bit of code I can try, I've tried using all of them at one, but nothing seems to work. If anyone has a suggestion, please help:
    import flash.external.ExternalInterface;
    import fl.controls.Button;
    import flash.events.MouseEvent;
    var lessonStatus:String;
    var lmsConnected:Boolean;
    var success:Boolean;
    lmsConnected = scorm.connect();
    if (lmsConnected) {
    lessonStatus = scorm.get("cmi.core.lesson_status");
    if (lessonStatus == "completed") {
    scorm.disconnect();
    } else {
    success = scorm.set("cmi.core.lesson_status", "incomplete");
    }
    } else {
    trace("Could not connect to LMS.");
    }
    var bookmark:Number;
    scorm.get("cmi.core.lesson_location");
    scorm.set("cmi.core.lesson_location","myBookmarkInStringFormat");
    function Initialize():Boolean {
    var R:Boolean;
    var msg:String = "LMS Communication Initialized: ";
    var initCheck = ExternalInterface.call("doLMSInitialize");
    msg += initCheck;
    if (initCheck == "true") {
    log_txt.text += msg+"\n";
    SetValue("cmi.core.lesson_status","incomplete");
    bookmark = Number(GetValue("cmi.core.lesson_location"));
    R = true;
    } else {
    log_txt.text += msg+"\n"+"Initialized Failed :( \n";
    R = false;
    }
    return (R);
    }
    function SetValue(n:String, v:String):Void {
    var R:Boolean;
    var msg:String = "SetValue ( '"+n+"' , '"+v+" '): ";
    var doSetValue = ExternalInterface.call("doLMSSetValue", n, v);
    log_txt.text += msg+"\n";
    }
    function GetValue(n:String):String {
    var R:String;
    var msg:String = "GetValue ( '"+n+"'): ";
    var doGetValue = ExternalInterface.call("doLMSGetValue", n);
    msg += doGetValue;
    log_txt.text += msg+"\n";
    R = String(doGetValue);
    return (R);
    }
    function Terminate():Void {
    var R:Boolean;
    var msg:String = "LMS Communication Terminating... ";
    var termCheck = ExternalInterface.call("doLMSFinish");
    }


    next_btn.onRelease = function ()
    {
    nextFrame();
    bookmark = _currentframe;
    SetValue( "cmi.core.lesson_location", String( bookmark ) );
    }

    back_btn.onRelease = function ()
    {
    prevFrame();
    bookmark = _currentframe;
    SetValue( "cmi.core.lesson_location", String( bookmark ) );

    }

    exit_btn.onRelease = function ()
    {
    Terminate();
    }

    I honestly have no idea what's going on or what to do. I'm new to e-learning. I was just handed a course and told to make it SCORM compliant by last week. It's telling the LMS whether or not the user has completed the lesson, but it's not bookmarking their progress. Someone, please help me.
    • CommentAuthorphilip
    • CommentTimeMay 5th 2008 edited
     
    Hi Mark

    Looks like you're not using my pipwerks wrapper & ActionScript class. They were designed to simplify working with SCORM, so I recommend you use them. :)

    You also have AS2 syntax in your AS3, which will throw an error.


    In the HTML:
    Step 1: Delete all SCORM-related JavaScript (including link to APIWrapper.js)
    Step 2: Add my pipwerks SCORM_API_wrapper.js file

    In the ActionScript:
    Step 1: Import the pipwerks AS3 SCORM class
    Step 2: Remove all references to the old SCORM code.

    Try this:


    import flash.external.ExternalInterface;
    import fl.controls.Button;
    import flash.events.MouseEvent;

    import pipwerks.SCORM;

    var lmsConnected:Boolean;
    var success:Boolean;

    var lessonStatus:String;
    var bookmark:Number;

    var scorm:SCORM = new SCORM();

    function init():void {

    lmsConnected = scorm.connect();

    if (lmsConnected) {

    lessonStatus = scorm.get("cmi.core.lesson_status");

    //In SCORM 1.2, completed & passed both indicate completion
    if (lessonStatus == "completed" || lessonStatus == "passed") {

    scorm.disconnect();

    } else {

    success = scorm.set("cmi.core.lesson_status", "incomplete");

    //If scorm.set was successful, perform other actions
    if(success){

    //Get the bookmark from the LMS, if available
    var lesson_location:String = scorm.get("cmi.core.lesson_location");

    if(lesson_location != null && lesson_location != ""){

    //Since your bookmark is a number, you need to convert it from string
    bookmark = Number(lesson_location);

    //Do whatever you want to do with the bookmark here
    //If the bookmark is a frame number, you coudl do:
    gotoAndStop(bookmark);

    } else {

    //Go to your default first frame

    }

    }

    }

    } else {
    trace("Could not connect to LMS.");
    }

    }

    init();



    In your button handler code, add a setBookmark function.

    function setBookmark(frameNumber:Number):void {
    bookmark = frameNumber;
    scorm.set("cmi.core.lesson_location", frameNumber.toString());
    }

    function nextBtnHandler(e:Event):void {
    setBookmark(_currentframe);
    nextFrame();
    }

    function backBtnHandler(e:Event):void {
    setBookmark(_currentframe);
    prevFrame();
    }

    function exitBtnHandler(e:Event):void {
    scorm.disconnect();
    }


    Hopefully this will get you going. Good luck

    - philip
    • CommentAuthormark.b
    • CommentTimeMay 6th 2008
     
    Question, Should I just ignore the 6 errors that cropped up?
    "class or interface 'pipworks.SCORM'could not be loaded."
    "A type identifier is expected after the ':'." (x2)
    "class or interface 'Event' could not be loaded." (x3)

    Sometimes these things can be handled outside of flash, so I'm thinking that this is the case, but I'm new to AS3 (having worked in AS1&2 the last several years) and don't know what's changed.
    • CommentAuthormark.b
    • CommentTimeMay 6th 2008
     
    Let me attach a copy of my shell and .js, I'm having so many problems now. The components aren't working, the movies aren't loading, and the shell is just sweeping through every frame without stopping. I'm going to switch back to AS2, I'm more comfortable there.