Skip to main content
juresti
Known Participant
January 4, 2011
Question

Check value once swf is loaded

  • January 4, 2011
  • 2 replies
  • 592 views

There are 50 movies loaded sequentially. From Q1 thru Q29 I want to attach a particular title (mc) to the main movie and then for Q30 thru Q40 another and so on. The file is on an Learning Management Sytem so I'm using SCORM code.

A movie is loaded in a clip in the main movie. A bookmark is set.

_parent.saveBookmark("Q1");

_parent.test1();

The main move has this code on the first frame:

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();
var mySubstring:Number = Number(bookmark.substr(1));

//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);
}

function testi() {
    trace(mySubstring);
    trace("ahhh");
if (mySubstring <= 29 && isNaN(mySubstring) == true && bookmark !== undefined){
    attachMovie("title_foundational", "ttl_foundational", 1, {_x: 217, _y: 5});
}}

startPreload(swfURL);

I'm lost.

This topic has been closed for replies.

2 replies

Participant
January 27, 2011

Hi, I noticed at the top of your code, you have _parent.test1 and at the bottom of your code, you call function testi<------ not sure if this helps..!!

_parent.saveBookmark("Q1");

_parent.test1();


// The main move has this code on the first frame:

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();
var mySubstring:Number = Number(bookmark.substr(1));

//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);
}

function testi() {
trace(mySubstring);
trace("ahhh");
if (mySubstring<=29 && isNaN(mySubstring) == true && bookmark !== undefined) {
  attachMovie("title_foundational","ttl_foundational",1,{_x:217, _y:5});
}
}
startPreload(swfURL);

juresti
jurestiAuthor
Known Participant
January 5, 2011

I want to do 4 things check to see if there is a bookmark, add if the number after the Q is <= 29 greater than 29 less than 30 do something, greater than 30 do something else, and finally add an underscore to the value of the variable bookmark.

var mySubstring:Number = Number(bookmark.substr(1));

//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);
}

juresti
jurestiAuthor
Known Participant
January 5, 2011

This worked:

if(bookmark.indexOf("Q") !== -1 && bookmark !== undefined && mySubstring <= 24){
    trace(mySubstring);
    attachMovie("title_foundational", "ttl_foundational", 1, {_x: 217, _y: 5}); 
    //add the underscore after the Q to match filename
      bookmark = bookmark.split("Q").join("Q_");
    swfURL = bookmark +".swf";
   trace(swfURL);}
else if   (bookmark.indexOf("Q") !== -1 && bookmark !== undefined && mySubstring > 25 && mySubstring < 37) {
    trace(mySubstring);
    attachMovie("title_mills", "ttl_mills", 1, {_x: 217, _y: 5}); 
    //add the underscore after the Q to match filename
      bookmark = bookmark.split("Q").join("Q_");
    swfURL = bookmark +".swf";
   trace(swfURL);}
else if   (bookmark.indexOf("Q") !== -1 && bookmark !== undefined && mySubstring >= 37) {
    trace(mySubstring);
    attachMovie("title_misc", "ttl_misc", 1, {_x: 217, _y: 5}); 
    //add the underscore after the Q to match filename
      bookmark = bookmark.split("Q").join("Q_");
    swfURL = bookmark +".swf";
   trace(swfURL);}