Josh
Josh

Reputation: 1

Call javascript function from flash button Flash CS5

I'm trying to show a div when someone clicks on the flash button pertaining to certain div. This is the javascript function I'm trying to have called:

<script type="text/javascript">
    function show1() {
        document.getElementById(#table1).style.display = 'block';
    }
</script>

"#table1" is the Div ID that I'm trying to display after the person clicks a button in flash. I haven't used flash in forever and am struggling finding the answer; it used to be you could just call it by going the getURL route, but that doesn't work any longer. Does anyone know how I would call that function to show the div?

Thanks in advance.

Upvotes: 0

Views: 3961

Answers (2)

KJYe.Name
KJYe.Name

Reputation: 17179

Update AS 3.0 Using ExternalInterface:

for some reason JavaScript doesn't work when tagged <script type="text/javascript"></script>. So, change your html part.

HTML:

<script language='javascript'>
function show1(){
      document.getElementById('table1').style.display = 'block';
}
</script>

Actionscript 3.0:

import flash.external.ExternalInterface;
button_1.addEventListener(MouseEvent.CLICK, function(){ 
     ExternalInterface.call("show1", "param");
});

Make sure in the html 'allowScriptAccess' is set to 'always' in AC_FL_RUnContent, object param, and embed.

Upvotes: 0

Myk
Myk

Reputation: 6215

You want to use ExternalInterface. Inside of flash just write ExternalInterface.call("show1");

Upvotes: 1

Related Questions