开发者

Flash:AS3, link a URL to a movie clip?

开发者 https://www.devze.com 2023-02-04 01:30 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号