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.");
}
Summary of Contents for DIRECTOR MX 2004
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...