PDA

View Full Version : Javascript Flash Comms


davevs
11-02-2004, 06:34 AM
I am currently developing eLearning modules using Flash and the SCORM standard. SCORM requires FLash and javascript to communicate. The method currently employed by most it seems is fscommand. I would prefer to use GET and POST with sendAndLoad, since fscommand has platform and browser issues (not that get and post don't). I have used GET and POST successfully with PHP etc but not with javascript the following example illustrates my point.

Actionscript:

myLoadVars = new LoadVars();
myLoadVars.sendAndLoad("javascript:hello();",myLoadVars,"POST");

This fragement is intended to call a function hello() in the HTML page which just raises an alert.

HTML/Javascript:

<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
<script language="javascript">
function hello() {
alert("hello");
}
</script>

</HEAD>
<BODY bgcolor="#FFFFFF">
<!-- URL's used in the movie-->
<!-- text used in the movie-->
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="800" HEIGHT="600" id="Untitled-1" ALIGN="">
<PARAM NAME=movie VALUE="Untitled-1.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="Untitled-1.swf" quality=high bgcolor=#FFFFFF WIDTH="800" HEIGHT="600" NAME="Untitled-1" ALIGN=""
TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT>
</BODY>
</HTML>

My problem: This works in Mozilla, but not in IE.

Any ideas .....

binkyboo
02-11-2005, 03:17 PM
Just a note to those who may run a search on SCORM, there is no SCORM conformant method for Flash content to communicate with a LMS through methods such as Web services or HTTP requests. Data element parameters must be sent through an API for communication to occur between a SCO and the LMS.

tg
02-11-2005, 06:33 PM
here's an example of something you might try...
this is what i did on a project i wrote about 2-3 years ago:

//html file that holds the flash file
<script language="JavaScript">
<!--//hide

function centerMe(){
var moveToX, moveToY;
moveToX=(window.screen.availWidth-870)/2;
moveToY=(window.screen.availHeight-600)/2;
window.moveTo(moveToX,moveToY);
}
//set up a function to tell the page that opened this page to load the selected provider
//then close this page
function openParent(pcsa,pn){
window.opener.location.href="../match.cfm?pcsa="+pcsa+"&prov="+pn;
window.close();
}
//unhide -->
</script>



// code to interface with javascript
pm.onRelease = function() {
getURL("javascript: openParent('"+loader.pcsa+"','"+this.provNbr+"');");
};


sometimes you may need to add void(0); to your getURL... like:
getURL("javascript: myfunction();void(0);");