If
you have your own tutorials or open
source and would like to share your
Director knowledge please send them
to info@shocksites.com.
We will review them, post it and give
full credit to the developer.
Hyperlinks and
Text Members Provided by Ivan
Bachev
This is a very helpful
tutorial on how to use
plain text and use them
as hyperlinks. This method
can be used for emails,
web address, ftp, and
more. It also automatically
changes the colors and
attributes of the text
areas with “www”,
“http:”, “@”
and others.
This tutorial is very
useful. Just type in a
block of text, and the
behavior and any thing
with a
"http". "@",
"www"
or what ever will automatically
become a hyperlink! Of
course you can always
edit the behavior to make
have other hyperOnic
superpowers!
Now I must warn you,
Ivan is not much on small
talk, but he sure gets
down to business! Now
this is how it goes:
SHOCKWAVE SAMPLE:
THE
CODE
--dedicated to the
greatest instigator
of the "hypernization"
- K A K Y O A N
A
--when attached,
this behavior makes
all the hyperlinks
in a text member
(http;//, www, @)
active, and gives
possibility to change
their colors.
--note that if
your text member,
on which you are
attaching the behaviour,
is quite a big one
like this one, it
would taka some
time in authoring
mode for the lingo
to process it.
--there is global
that after the lingo
process the text
member, it would
not take time again.
--if you once "hypernize
your text with this
behavior, comment
the whole "on
mouseenter me"
code.
global currentMember,
is --globaling the
assigned member
so to be used in
the mousenter nad
mousedown event
property spriteNum
--
on
mouseenter me
if
is<>1 then
-- this is a global
that checks if all
the "hypernisation"
is allready done
--
member(the
mousemember).useHypertextStyles=false
--
currentMember
= sprite(1).member
--assigning the
member
--
repeat
with i=currentMember.word.count
down to 1
--putting all the
words in the member
in cycle and repeating
through it so to
find the words containing
"http",
"www"
and "@"
--
if
currentMember.word[i]
contains "http://"
then
currentMember.word[i].hyperlink="#"
--assigning fake
value to the whole
word containing
"http",
"www"
and "@"
so to hperlink it
therefore change
cursor on hand when
point it
currentMember.word[i].foreColor=200
--the colour of
the link
currentMember.word[i].fontStyle
=[#underline]
-- the font style
of the hyperlink
end
if
--
if
currentMember.word[i]
contains "www."
then
currentMember.word[i].hyperlink="#"
currentMember.word[i].foreColor=200
currentMember.word[i].fontStyle
=[#underline]
end if
--
if
currentMember.word[i]
contains "@"
then
currentMember.word[i].hyperlink="#"
currentMember.word[i].foreColor=140
currentMember.word[i].fontStyle
=[#underline]
end if
--
end
repeat
is=1--asigns
a value to the global
so not to repeat
the hypernization
action every time
you enter the text.
end
if
end
--
on
mousedown me
pointClicked = the
mouseLoc
wordNum = sprite(1).pointToword(pointClicked)
--chechking the
hyperlink word number
when it is clicked
wordText
= currentMember.word[wordNum]
--geting the text
of the clicked word
--
if
wordText contains
"@" then
goToNetPage("mailto:"
& wordText)
end if
--
if
wordText contains
"http://"
then
goToNetPage(wordText)
--performing the
gotonetpage command,
it will the url
which text is the
text of the clicked
word
end
if
--
if
wordText contains
"www."
then
goToNetPage(wordText)
end if
--
end
----------------------------------------------------------------------------
-------------------------------------------------------
--httpwww@
--you can add check
for "ftp."
for example or other
protocols
----------------------------------------------------------------------------
-------------------------------------------------------
on
mousewithin me
-- changes and restores
the cursor when
the mouse is over
hyperlink
if
pointInHyperlink(sprite
the currentspritenum,
the mouseloc)=1
then
cursor 280
end if
if pointInHyperlink(sprite
the currentspritenum,
the mouseloc)=0
then cursor -1
end