# NavigateURL Problem

**URL:** <https://forum.kirupa.com/t/navigateurl-problem/327216>\
**Category:** flash\
**Created:** [February 13, 2012, 3:07pm UTC](https://forum.kirupa.com/t/navigateurl-problem/327216 "2012-02-13T15:07:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![leighgoodman](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@leighgoodman](https://forum.kirupa.com/u/leighgoodman)\
**Post date:** [February 13, 2012, 3:07pm UTC](https://forum.kirupa.com/t/navigateurl-problem/327216/1 "2012-02-13T15:07:39Z")

</div>

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
