0

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.

5
  • I found out that this example will only work embedded in a html file which is run on a real http server. Does anyone know why? Commented Mar 5, 2011 at 22:49
  • I used: mtasc.exe -swf dummy.swf -main dummy.as Commented Mar 5, 2011 at 22:51
  • Please somebody close this post: due to security restrictions it's forbidden to execute .swf files locally. For further information please look to the Adobe site. Commented Mar 5, 2011 at 23:00
  • @Mike ...this is your post, and you can execute swf files locally. As far as why it only work when embedded in an html is because flash doesn't understand javascript's syntax. getURL is expecting to work with a browser. adobe.com/support/flash/action_scripts/actionscript_dictionary/… Commented Mar 5, 2011 at 23:00
  • @Mike Dooley It is because getURL is executed by the host application (whis has the Flash plyer embedded). If you are in a standalon Flash Player, it has no JS support so the URL will not work. If your browser opens it a local file, mybe for security reasons it can block getURL. Commented Mar 5, 2011 at 23:02

2 Answers 2

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>
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.