Have just tried to get your sample code working with Flex 2 running in Moodle 1.8 - any ideas why I should be getting "Error code 401 - undefinited data model" when I add:
variableName = scorm.get("cmi.core.student_id");
after the call to scorm.connect();? It does say that it connected, but it doesn't seem to like my added syntax.
cmi.core.student_id is a SCORM 1.2-specific call. According to the SCORM 1.2 docs (page 29 of 85 of the SCORM_1.2_RunTimeEnv.pdf), a 401 error on cmi.core.student_id means the LMS doesn't support that call ("not implemented").
If you're trying to use SCORM 2004, the syntax for cmi.core.student_id has changed to cmi.learner_id.