You can put JavaScript right inside of the AS3 as follows:
Code:
import flash.external.*;
var JStodo:XML =
<script>
<![CDATA[
function (marg) {
function dothis(forarg)
{
alert(forarg);
};
dothis(marg);
//the function in dothis can be any function defined in the wrapper
}
]]>
</script>;
//calling the script
if (ExternalInterface.available)
{ExternalInterface.call(JStodo);}
hope this helps