主题:  关于文本超连接

shenxinli

职务:普通成员
等级:1
金币:0.0
发贴:8
#12001/3/10 12:23:25
如何在filed或text中,使文字能够进行超链接(不是分开做cast)????



5D精英

职务:普通成员
等级:3
金币:10.0
发贴:1340
#22001/3/10 12:36:57
Creating a hyperlink

In the Text Inspector, you can turn any selected range of text into a hyperlink that links to a URL or initiates other actions. Director automatically adds standard hyperlink formatting to the selected text so that it initially appears with blue underlining. You can turn off this formatting in the Text tab of the Property Inspector. See Setting text or field cast member properties.
The following procedure describes how to add a hyperlink to selected text. To make a hyperlink actually do something, you need to write an on hyperlinkClicked event handler. See on hyperlinkClicked.

You can enter any string in the hyperlink box; it does not have to be a URL. The string cannot contain a double quotation mark or the Lingo continuation character.

To define a hyperlink:

1    Select the text you want to define as a hyperlink.
2    Choose Window > Inspector > Text to open the Text Inspector.
3    In the Hyperlink box, enter the URL to which you want to link, or enter any message you want to send to the on hyperlinkClicked handler. Then press Enter (Windows) or Return (Macintosh).
Syntax    on hyperlinkClicked me, data, range

statement(s)

end

Description    System message and event handler; used to determine when a hyperlink is actually clicked.

This event handler has the following parameters:

me桿sed in a behavior to identify the sprite instance
    data桾he hyperlink data itself; the string entered in the Text Inspector when editing the text cast member
    range桾he character range of the hyperlink in the text (It抯 possible to get the text of the range itself by using the syntax member Ref.char[range[1]..range[2]]

This handler should be attached to a sprite as a behavior script. Avoid placing this handler in a cast member script.

Example    This behavior shows a link examining the hyperlink that was clicked, jump to a URL if needed, then output the text of the link itself to the message window:

property spriteNum

on hyperlinkClicked me, data, range
    if data starts "http://" then
        goToNetPage(data)
    end if
    currentMember = sprite(spriteNum).member
    anchorString = currentMember.char[range[1]..range[2]]
    put "The hyperlink on"&&anchorString&&"was just clicked."

end