So, I've been avoiding posting this question because of the shear amount of prior posts. I've tried several variations of the following code, and to no avail.
I'm using FireFox (latest), Flash Player (latest), AS3, and A couple lines of JavaScript.
Here's my AS3 :
import flash.external.*;
// Handling Count For External Refreshing
var count: Number = 0;
var countMax: Number = 3;
function countHandler(): void {
if (count >= countMax) {
trace("The count has reached the max " + countMax);
ExternalInterface.call("refresh");
count = 0;
} else {
trace("The Count is " + count)
return;
}
}
I've traced the count, the total, all that, so I know that the code is working. It even resets the count when it gets to 3
Here's the javascript :
<script language="JavaScript">
function refresh() {
window.location.reload();
}
</script>
For giggles/testing, I added a button to the page to test that the above code is working...
<input type="button" value="Reload Page" onClick="refresh()">
When I press the button, it refreshes the page.
Is there something I'm missing? Why will the working AS3 Not refresh the page by triggering the working javascript?
When I click the button, it refreshes, when the code triggers via ActionScript, I'm unable to press any of the SWF buttons. So it's firing, but not actually refreshing the whole page.
Update July4th - Updated AS3 and Java - Still no Luck
Thanks to Akmozo for the help.
Set
allowScriptAccesstoalways- NOT*Like the adobe tutorial says (bastards). The SWF can't have any hyphens or dashes. I had to set the file name toMy.Test.File.flaso when I export/build it outputs the followingflashContentMore info on symbols in nomenclature - Here
Here is the ActionScript I used.
Here is the java script. Placed in
<head>below<style>I had to create a
crossdomain.xmlfile to allow access. I've tested the project several times with and without thecrossdomain.xmland it without it, I get asecurity sandboxerror. Not sure whyallowScriptAccess="always"isn't working.Conclusion So it appears that setting
allowScriptAccessto*is a bad idea. I got that from one of Adobe's Security Sandbox tutorials (thanks Adobe). Also, passing"refresh();"throughExternalInterface.calllooks forrefresharguments which there are none. TheSWffile name but not use dashes-like this..This...
MyFileName.swfNot this...
My-File-Name.swfThis code is executing as expected. Thank you all for your input and help.