Hi,
I'm a Flash / mtasc newbie. I am trying to get Javscript to Flash
communication working, and I am using the Swiff object from the
MooTools Javascript framework (I believe it is based on SWFObject).
I have tried two things:
- Calling a "actionScriptFunction" on the embedded object directly (I
say this suggested somewhere...). This results in an
'actionScriptFunction is not a function' error.
- Using the Swifff.remote function. This results in a
'__flash__argumentsToXML is not defined' error. I have seen other
MooTools codes that use this with Flash, and they appear to work fine
without this error. However, I don't know if they use mtasc.
Can anyone help?
Regards,
Michal.
//----------- Tuto.as file ---------//
import flash.external.ExternalInterface;
class Tuto {
static var app : Tuto;
function Tuto(scope:MovieClip) {
_root.createTextField("tf",0,0,0,800,600);
_root.tf.text = "Hello world !";
ExternalInterface.addCallback("actionScriptFunction",
actionScriptFunction);
}
public function actionScriptFunction(input:String):String {
_root.tf.text = "Called from Javascript";
return input;
}
static function main(mc) {
app = new Tuto(_root);
}
}
//----------- index.html file ---------//
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
">
<html xmlns="
http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript"><!--//--><![CDATA[//><!--
window.addEvent('domready', function() {
var obj = new Swiff('tuto.swf', {
id: 'myTuto',
width: 800,
height: 600
});
$('flash').empty().grab(obj);
console.log(obj.remote('actionScriptFunction'));
//console.log($('myTuto').actionScriptFunction());
});
//--><!]]></script>
</head>
<body><div>
<div id="flash"><p>Content to be replaced</p></div>
</div></body>
</html>
--
MTASC : no more coffee break while compiling