问题
I need flash to talk to jQuery.
Here is my Flash code:
if (ExternalInterface.available)
{
ExternalInterface.call('function(){ MyFunction(); }');
ExternalInterface.call('function(){ alert("Praise Be Jesus Christ!"); }');
}
The "Alert" works great. My function does not.
Here is my jQuery:
<script type="text/javascript">
$(document).ready(function()
{
$("#flashContentABOVE").click(MyFunction);
function MyFunction()
{
$("#flashContentABOVE").css("z-index", 4 );
}
});
</script>
回答1:
Put your <script>
tag at the bottom of your html file (before the closing <body>
), and take out the document.ready()
function.
回答2:
You should be able to call MyFunction directly from your swf. I always call ExternalInterface like:
ExternalInterface.call("funcName","param1","param2");
来源:https://stackoverflow.com/questions/10923705/as3-calling-jquery-function