Archive for the ‘Flash/ActionScript’ Category

Ctrl+Click in flash.

25 Mar, 08

I’ve recently been writing a news ticker at work in flash, which works really nice, it links news stories to parts of the site that are worth a look at. That’s all great, but what if you want to stay on the page you’re on? With Flash the answers usually simple, “change the target to ‘_blank’ and you’re on your way. But if you actually want it to act like a normal part of the website, you need another answer.

Firefox and ie7 let you use the tabbing system for this, click ctrl while you click and it opens in a new tab, but how would you go about it in flash?

Here’s my function to fix it:-


function ctrlClick(link)
{
var window = "_self";
if(Key.isDown(Key.CONTROL))
{
window = "_blank";
}
getURL(link, window);
}

That way you’re sorted. click ctrl when you click the link, it opens in a new window/tab, click it normally, it stays in the same window, job done.