0

i need help calling a javascript function from flash, i have embedded the flash using swfobject, heres my javascript to embedd it

<script type="text/javascript">
    swfobject.registerObject("myFlashContent", "9.0.0", "expressInstall.swf");
</script>

Here is my HTML which is used to show the flash

<div class="flash">
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="258" id="myFlashContent">
        <param name="movie" value="btnDemo.swf" />
        <param name="allowscriptaccess" value="always" />
        <!--[if !IE]>-->
            <object type="application/x-shockwave-flash" data="btnDemo.swf" width="258">
        <!--<![endif]-->
        <a href="http://www.adobe.com/go/getflashplayer">
            <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
        </a>
        <!--[if !IE]>-->
            </object>
        <!--<![endif]-->
    </object>
</div>

And in my flash i have, which should display a popup message

getURL("javascript:alert('hello')");

However, none of this is working.

Anyone have any ideas as to why this isn't working?

1 Answer 1

2

You should really use ExternalInterface for doing calls to JavaScript. Using it looks like this:

import flash.external.ExternalInterface;
if(ExternalInterface.available) ExternalInterface.call('alert','hello');

Using the availability test prevents the code throwing an error when running in the IDE.

Also, in your example you are targeting FP9, so your code must be AS3? AS3 has no getURL() method.

Sign up to request clarification or add additional context in comments.

2 Comments

Weirdly, that code now works. However it only works on a remote server, it doesn't work on my local server. The getURL() method works with the code above.
You might need to add access permissions for you local machine. Use the settings panel in the link to add trusted folders. macromedia.com/support/documentation/en/flashplayer/help/…

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.