views:

302

answers:

1

I have a textField on my stage named 'adBuy', which when clicked I want to open up my browser with the defined in URL request. However when I click on the 'adBuy' textField on my SWF it opens Coda, the piece of software I'm using to write this small piece of code?

I am puzzled. Here is my code:

adBuy.defaultTextFormat = adFormat;
adBuy.textColor = 0xFF65CB;
adBuy.x = 640;
adBuy.y = 455;
adBuy.text = "Buy Now";
parent.addChild(adBuy);

adBuy.addEventListener(MouseEvent.CLICK, buyAdvert);

var request:URLRequest = new URLRequest("http://www.google.co.uk");

function buyAdvert(event:MouseEvent):void {

    navigateToURL(request, "_blank");

trace("link clicked");
}

Is there an error in my code, or is this a common problem for which there is an answer?

A: 

Sorry, I have solved my problem.

It appears the reason it was not opening a web browser with the URL it because I was running the SWF through 'Test Movie' in Flash. This appears to have been stopping the code working.

It did however work fine when I ran it in Flash Player.

Ronnie