tags:

views:

19

answers:

3

hi,

I'm using

<mx:LinkButton label="www.google.com" click="navigateToURL(new URLRequest(event.currentTarget.label.toString()))" />

to open a browser window to display the website on the label of my LinkButton. However I cannot correctly pass the link.. you see the problem:

file://localhost/..myapp/bin-debug/www.google.com

thanks

A: 

I'm suspecting that the text is something like "google.com" rather than an absolute url.

Try this:

<mx:LinkButton label="www.google.com" click="navigateToURL(new URLRequest('http://' + event.currentTarget.label.toString()))" />
Saheed
sorry I've accidentally removed it. I've updated the question.
Patrick
A: 

Usually when defining links there are three ways they will be interpreted:

  • xy/file.ext is a relative reference using the current folder as the starting point. It is equivalent to ./xy/file.ext in that way.
    So when you are at http://example.com/subdirectory/index.html, it get's interpreted as http://example.com/subdirectory/xy/file.ext.
  • /xy/file.ext is a relative reference using the host's root as the starting point.
    So in the above situation the link would lead to http://example.com/xy/file.ext.
  • The other method is by specifying an absolute link. This is the solution you should use to navigate to a different host, so especially in your case where you want to link to google. Simply specify the full host with the protocol: http://google.com as the link target and it will work.
poke
A: 

The problem you're having is that you didn't add "http://" to the beginning. Most browsers can adjust for that because they're built to assume you mean http:// if you leave it out - but Flash Player won't adjust for that, since in theory you could be referring to a file on your hard drive or whatever.

Either add the http:// to your label or to your URLRequest.

Myk