Pass data from action script to javascript

2019-06-09 08:45发布

问题:

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:

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>