问题
I'm not familiar with ActionScript and for some reason the following code won't work, although it was mentioned that way in a tutorial:
class Dummy {
function Dummy() {
}
static function main(mc) {
getURL("javascript:alert('works!')");
}
}
I used "mtasc" to compile the script.
回答1:
when you're embedding the flash file in your page are you setting allowscriptaccess="true"
so like:
<embed src="flash.swf" allowscriptaccess="true"></embed>
回答2:
Did you specify a document class for your flash file? You aren't actually calling the function that calls your javascript anywhere in the code above. If you put the "getURL" line into function Dummy and specify Dummy as your document class, your code will execute. Otherwise, within dummy, make a call to main(). Also just a note that currently there's no reason to have (mc) as a passed parameter in that function.
来源:https://stackoverflow.com/questions/5207260/call-javascript-function-within-actionscript