Hi, I am creating a CD-rom presentation in AS3 (this is the first time I am working in AS3)
I have as button that needs to open up a local file called work.html
I tried this (which apparently should work, and it gives me no errors, BUT it does not work in firefox)
1st Attempt
but2.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(e:MouseEvent):void {
var request:URLRequest = new URLRequest(“work.html”);
navigateToURL(request, “_blank”);
}
Then i did some research into firefox problem, but all are not working for me. All gives me errors.
Eg - the code i used for the "fix is this:
2nd Attempt
var swfDir:String = _root._url;
var lastSlash:Number = swfDir.lastIndexOf("/");
var colonSpot:Number = swfDir.indexOf("|");
var myUrl:String;
if(colonSpot>=0){
/that means if we found a “|” if we didn’t the colonSpot value would be -1/
myUrl = swfDir.substring(0,colonSpot);
/that makes our Url var = everything BEFORE the “|”/
myUrl +=":"
/* that ads the “:” /
}else{
myUrl="";
}
myUrl+= swfDir.substring(conolSpot+1, lastSlash+1);
/ now we just added back everything after the | */
function newGetUrl(event:MouseEvent):void{
var targetUrl:URLRequest = new URLRequest(myUrl + “work.html”);
navigateToURL(targetUrl, “_blank”);
}
but2.addEventListener(MouseEvent.CLICK, newGetUrl);
The errors i get are:
Both 1120 errors - for undefined properties _root and conolSpot
???
Any help would be much appreciated!!
Thanks,
Leigh