Using ActionScript 2.0, in order to get through the security sandbox crap, you need to use
ExternalInterface. Add these lines of code to the main timeline:
[color=#800080]import flash.external.*;
function gotoHTMLPage(url) {
//------------------------------------
// The name of a JavaScript function to call.
var goPage:String = "gotothePage";
//------------------------------------
// Calling JS function
ExternalInterface.call(goPage,url)
//------------------------------------
}[/color]
These lines of code are in the button or in the frame where the button is located in the timeline:
[color=#800080]// Where [i]btn_Name[/i] is the name of your button and the use of [i]_root[/i] calls the [i]gotoHTMLPage[/i] from anywhere in the Flash file.
btn_Name.onPress = function() {
_root.gotoHTMLPage("http://www.yahoo.com");
};[/color]
The last piece of code needs to be in a .js file or in a script tag in the HTML page that contains the swf file:
[color=#800080]<script language="javascript">
function gotothePage(url){
window.open(url);
}
</script>[/color]
There are more elegant ways to do this using ActionScript 3, but this should get rid of any sandbox problem you might have when accessing Javascript code from your swf file.
One last thing, one of the settings in the swf file tag,
allowScriptAccess needs to be set to
always when testing from a local machine. I believe you leave it at the default setting when its hosted on a server.
<param name="allowScriptAccess" value="sameDomain" /> Default setting
<param name="allowScriptAccess" value="always" /> Avoid Security Sandbox problems for local testing
Hope this helps some people out there.
Alto Banor
Edited by moderator, 29 March 2012 - 05:27 AM.