Copy link to clipboard
Copied
I need to trigger a AS function when a user close the browser window. This is what I've done so far... but no luck.
AS:
import flash.external.*;
function test1() {
//do something
}
JS:
<script type="text/javascript">
window.onbeforeunload = function(){
test1();
return 'text here' };
</script>
use:
AS:
import flash.external.*;
ExternalInterface.addCallback("jsCallF",null,test1);
function test1(s:String) {
//do something with s
}
JS:
<script type="text/javascript">
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName]
}
else {
return document[movieName]
}
}
window.onbeforeunload = function(){
thisMovie("your_swfs_embed_tag_name").jsCallF('text here');
};
</script>
and you'll need to use embedding code compatibl
...Copy link to clipboard
Copied
use:
AS:
import flash.external.*;
ExternalInterface.addCallback("jsCallF",null,test1);
function test1(s:String) {
//do something with s
}
JS:
<script type="text/javascript">
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName]
}
else {
return document[movieName]
}
}
window.onbeforeunload = function(){
thisMovie("your_swfs_embed_tag_name").jsCallF('text here');
};
</script>
and you'll need to use embedding code compatible with the externalinterface class. swfobject works and there's code shown in the adobe help files that also works.
and you'll need to use the correct name in place of your_swfs_embed_tag_name.
Copy link to clipboard
Copied
you're amazing... thanks!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now