Trying to call a very basic javascript function (AS2)


I’m trying to do something very basic for testing purposes :

I’ve got an Actionscript 2 document with a movie clip in it.

I want that when one clicks on the movie clip, a Javascript function executes. This Javascript function is defined in the <head> of the html document that contains the SWF.

This is what I’ve got so far on the Actions layer of my movie clip :

test_mc.onRelease = function(){

and this is what’s in my HTML file :

<script type="text/javascript">
			function helloWorld() {
		           alert('Hello World');

When I click on the movie clip in the web page, I get a pop up that says “Adobe Flash player has stopped a potentially unsafe operation…”

Any ideas? Must be something really silly right?

You need to allow scripting in the embed parameters.

Hi EastCoast,

I thought I had allowed scripting. I used a piece of software to generate the SWF Object 2.2 code and this is what I’ve got :

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="725" height="710" id="myFlashContent">
    <param name="movie" value="afrique.swf" />
    <param name="allowscriptaccess" value="always" />
<!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="afrique.swf" width="725" height="710">
    <a href="">
    <img src="" alt="Get Adobe Flash player" />
<!--[if !IE]>-->

Is it no good ?

You seem to be missing the allowscripting param within the if !IE nested object, it should be repeated again there. Use if you’re not already to generate the code

Thanks EastCoast, I think that’s the same generator I’m using - a desktop version of it- but it doesn’t seem to include the allowscripting param. I thought I’d added it but like you said there is one bit missing. I’ll try to find it somewhere.