Call JavaScript function within ActionScript

家住魔仙堡 提交于 2019-12-11 20:42:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!