开发者

Call javascript function from flash button Flash CS5

开发者 https://www.devze.com 2023-02-10 10:56 出处:网络
I\'m trying to show a div when someone clicks on the flash button pertaining to certain div.This 开发者_Python百科is the javascript function I\'m trying to have called:

I'm trying to show a div when someone clicks on the flash button pertaining to certain div. This 开发者_Python百科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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消