-
ExternalInterface question
How would I call this javascript function and recieve the error code back if any.
code:
import flash.external.ExternalInterface;
ExternalInterface.call("SCOInitialize", My_error );
function My_error(err:String )
{
mytext_txt.text = err;
}
My java script function
Code:
function SCOInitialize() {
var err = true;
if (!g_bInitDone) {
if ((window.parent) && (window.parent != window)){
g_objAPI = FindAPI(window.parent)
}
if ((g_objAPI == null) && (window.opener != null)) {
g_objAPI = FindAPI(window.opener)
}
if (!APIOK()) {
AlertUserOfAPIError(g_strAPINotFound);
err = false
} else {
err = g_objAPI.LMSInitialize("");
if (err == "true") {
g_bSCOBrowse = (g_objAPI.LMSGetValue("cmi.core.lesson_mode") == "browse"); if (!g_bSCOBrowse) {
if (g_objAPI.LMSGetValue("cmi.core.lesson_status") == "not attempted") {
err = g_objAPI.LMSSetValue("cmi.core.lesson_status","incomplete")
}
}
} else {
AlertUserOfAPIError(g_strAPIInitFailed)
}
}
if (typeof(SCOInitData) != "undefined") {
// The SCOInitData function can be defined in another script of the SCO
SCOInitData()
}
g_dtmInitialized = new Date();
}
g_bInitDone = true;
return (err + "") // Force type to string
}
-
Code:
import flash.external.ExternalInterface;
var err:String = ExternalInterface.call("SCOInitialize");
My_error(err);
function My_error(err:String ):void{
mytext_txt.text = err;
}
SCOInitialize does not take any arguments, but you were trying to pass My_error as one. The return value of SCOInitialize was being thrown away, but that's what you wanted to pass to My_error.
-
Your correct i don't want to pass anything to sco initialize. Thanks for correcting my code.
Its throwing an error and the swf will not run now though
TypeError: Error #2007: Parameter text must be non-null.
at flash.text::TextField/set text()
at simple_fla::MainTimeline/My_error()
at simple_fla::MainTimeline/frame1()
-
Looks like the return value from the javascript was null. You'll need to check for that in your function.
-
Thanks I got it corrected now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|