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
AS3 MouseEvent.CLICK not working in browser
-
29-03-2022 - |
Frage
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);
Lösung 2
Andere Tipps
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");
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow