James Hollingworth
James Hollingworth

Reputation: 14210

Calling JS from a flash video

I need to create a really basic flash video (actionscript 2) where I click on a bit of text which will call a javascript function. I'm really new to actionscript so please forgive me if this is a trivial question...

I have created a flash video which has a bit of text I converted to a button symbol. I then opened the "Actions" tab and added:

on (press) {
    import flash.external.ExternalInterface;
    ExternalInterface.call("test");
    trace("Foo");
}

Which when I debug will print "Foo" to the output window. However when I put this flash video on a page with the following js in the header nothing happens...

<script language="javascript" type="text/javascript">
    function test() {
        alert("Hey");
    }
</script>

I thought that it might be something to do with ExternalInterface.call so I tried getUrl("javascript:test()") which popped up a security warning (so the pressed event must be firing) but then did nothing when I ok'd the warning.

Anyone got any ideas?

Upvotes: 2

Views: 513

Answers (1)

Lars Bl&#229;sj&#246;
Lars Bl&#229;sj&#246;

Reputation: 6127

Your scripts looks OK to me, maybe it could be that you need to set the AllowScriptAccess parameter in the HTML (or SwfObject JavaScript) that embeds the swf in the HTML page.

Upvotes: 1

Related Questions