开发者

Call JavaScript function within ActionScript

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.


when you're embedding the flash file in your page are you setting allowscriptaccess="true"

so like:

<embed src="flash.swf" allowscriptaccess="true"></embed>


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜