Flash:AS3, link a URL to a movie clip?
I need to be able to click text in my movie and have it take me to a website. Right now the text开发者_开发技巧 is just a movie clip and it slides in from the right.
Thanks in advance :]
You can capture the mouse click on the movie clip and send it to the url (B hackish). Or you can use html in a TextField (A if your text field is dynamic), in case you have a static TextField, C.
A Hand cursor will show only over actual link.
tf.htmlText = 'Create link with <a href="http://www.example.com">TextField.htmlText</a>';
B Hand cursor will show over clip.
clip.addEventListener(MouseEvent.CLICK, myBtnClicked);
clip.buttonMode = true;
function myBtnClicked(e:MouseEvent):void {
var url:String = "http://www.example.com";
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, '_blank');
} catch (e:Error) {
trace("Error occurred!");
}
}
C In the flash IDE, having the textfield instance selected, look into the properties panel, under options you can specify a link for the textfield.
精彩评论