176
Chapter 10: Events and Messages
on hyperlinkClicked
Usage
-- Lingo syntax
on hyperlinkClicked
me, data, range
statement(s)
end
// JavaScript syntax
function hyperlinkClicked(
data, range)
{
statement(s);
}
Description
System message and event handler; used to determine when a hyperlink is actually clicked.
This event handler has the following parameters:
•
me
Used in a behavior to identify the sprite instance
•
data
The hyperlink data itself; the string entered in the Text inspector when editing the text
cast member
•
range
The character range of the hyperlink in the text (It’s 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:
-- Lingo syntax
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
// JavaScript syntax
function hyperlinkClicked(data, range) {
var st = data.slice(0,7);
var ht = "http://";
if (st = ht) {
gotoNetPage(data);
}
var currentMember = sprite(this.spriteNum).member;
var r1 = currentMember.getPropRef("char", range[1]).hyperlinkRange;
var a = r1[1] - 1;
var b = r1[2];
var st = new String(currentMember.text);
var anchorString = st.slice(a, b);
put("The hyperlink on " + anchor " was just clicked.");
}
Содержание DIRECTOR MX 2004-DIRECTOR SCRIPTING
Страница 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Страница 48: ...48 Chapter 2 Director Scripting Essentials...
Страница 100: ...100 Chapter 4 Debugging Scripts in Director...
Страница 118: ...118 Chapter 5 Director Core Objects...
Страница 594: ...594 Chapter 12 Methods...
Страница 684: ...684 Chapter 14 Properties See also DVD...
Страница 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Страница 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Страница 889: ...netPresent 889 _player alert Sorry the Network Support Xtras could not be found See also Player...
Страница 1102: ...1102 Chapter 14 Properties...