Pass data from action script to javascript

2019-06-09 08:39发布

Does anyone know if I can pass data from flash (action script) to java script? If yes... how?

(I need to send an ajax request with a text typed inside a textbox from actionscript).

1条回答
beautiful°
2楼-- · 2019-06-09 09:19

You can use ExternalInterface to interact w/ JavaScript

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

for some reason i run into issues if i declare JavaScript tag type='text/javascript'. so i recommend using:

<script language='javascript'>
function myFunc(myparam){
      //your code
}
</script>
查看更多
登录 后发表回答