Domanda

The ActionScript 3.0 code below works when tested in Adobe Flash CS6, however when tested in a browser the code does not work. Any ideas why this is happening?

buttonInstance.addEventListener(MouseEvent.CLICK,function(e:MouseEvent){
    flash.net.navigateToURL(new URLRequest("http://facebook.com"), "_blank"); 
    trace("link clicked");
},false,0,true);
È stato utile?

Soluzione 2

The problem was I had 'Local playback security' set to 'Access local files only' I changed it to 'Access network on only' and it works. This post helped AS3 Flash URLRequest not working upon export

Altri suggerimenti

The event listener's probably being garbage-collected. You need to change your code to one of the following:

buttonInstance.addEventListener(MouseEvent.CLICK,function(e:MouseEvent){
    flash.net.navigateToURL(new URLRequest("http://facebook.com"), "_blank"); 
    trace("link clicked");
}); // (false, 0, false)

or:

    buttonInstance.addEventListener(MouseEvent.CLICK,onClick,false,0,true);
.
.
.
private function onClick(pEvent:MouseEvent):void
{
    flash.net.navigateToURL(new URLRequest("http://facebook.com"), "_blank"); 
    trace("link clicked");
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top