开发者

Call JavaScript function within ActionScript

开发者 https://www.devze.com 2023-02-15 14:12 出处:网络
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:

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

精彩评论

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

关注公众号