oneillpaul70
asked on
Hyperlink problem
Ive set up a hyperlink in director 8.5 as follows. I created a text box and highlighted the data, then went to Window - Inspectors - Text and entered in the website i wanted to go to. I then added the following behavior to my movie so that whenever I clicked on a hyperlink the proper page would open up.
on hyperlinkClicked me, data, range
case true of
(data starts "www."): gotoNetPage(data, "new")
(data starts "event"): alert "The hyperlink "& data & " was just clicked."
end case
end
The hyperlinks worked fine whenever I played them in director but when I published the movie as a shockwave, the hyperlinks would no longer work. Instead when I clicked on them they would be added to the end of the existing web-address. This is an example of what would happen
ORIGIONAL MOVIE
http://ijsr32.infj.ulst.ac.uk/~99419971.e410uj4.students/
WHEN I CLICK ON A HYPERLINK
http://ijsr32.infj.ulst.ac.uk/~99419971.e410uj4.students/www.technologyreview.com
(Please note you will not be able to access the above website)
I was wondering if there was a way so that when a user clicked on a hyperlink this would open the link in a new web-page. Please note there are 9 possible hyperlinks that could be clicked. If anyone could tell me how to do this I would appreciate it very much.
Thanks Paul
on hyperlinkClicked me, data, range
case true of
(data starts "www."): gotoNetPage(data, "new")
(data starts "event"): alert "The hyperlink "& data & " was just clicked."
end case
end
The hyperlinks worked fine whenever I played them in director but when I published the movie as a shockwave, the hyperlinks would no longer work. Instead when I clicked on them they would be added to the end of the existing web-address. This is an example of what would happen
ORIGIONAL MOVIE
http://ijsr32.infj.ulst.ac.uk/~99419971.e410uj4.students/
WHEN I CLICK ON A HYPERLINK
http://ijsr32.infj.ulst.ac.uk/~99419971.e410uj4.students/www.technologyreview.com
(Please note you will not be able to access the above website)
I was wondering if there was a way so that when a user clicked on a hyperlink this would open the link in a new web-page. Please note there are 9 possible hyperlinks that could be clicked. If anyone could tell me how to do this I would appreciate it very much.
Thanks Paul
(data starts "www."): gotoNetPage( "http:///" & data, "new")
ASKER
Is there anyway I can have it so that a different browser window is opened each time or that when 1 user clicks on a link the same web-page opens on the other users screen.
Yes.. Instead of "new" use "_blank"
As for the second option, I am not sure I follow. If you are trying to make one PC open files on another you will need to send messages via multiuser server or Flash Comm server.
As for the second option, I am not sure I follow. If you are trying to make one PC open files on another you will need to send messages via multiuser server or Flash Comm server.
ASKER
I am using the multiuser for i have set up a text based chatroom using it and the hyperlinks are one of the features of it so I was wondering if a user clicked a hyperlink in 1 computer could the same hyperlink be opened up on a different computer without having to press anything
Yes...
The hyperlink would execute a send message to the other user. Then that user's program would pick up the event and issue a goToNetPage.
The hyperlink would execute a send message to the other user. Then that user's program would pick up the event and issue a goToNetPage.
ASKER
I was also wondering is there anyway I can change the hyperlink color once I have clicked on a hyperlink and when I tried the "_blank" instead of "new" the link was still opened up in the same window
Not be default in Director but I have a behavior at www.mediamacros.com that will do this. THe direct url to it is...
http://www.mediamacros.com/item/item-1006687110/
http://www.mediamacros.com/item/item-1006687110/
ASKER
Ive also been trying to set up a button whereby if a user enters an address of a website into a text button and then presses a button that a hyperlink to that site will be opened if it exists but ive been having no luck with this. Would you now if this is possible and is so could you please show me how to do it.
Thanks
Thanks
ASKER
I added the above code for the changing colour of the hyperlinks to the property of the text buttons. Was this the correct place to add it to? As when I clicked on a link the text would change colour but the hyperlink that I had setup would not work.
Place my code above in a separate behavior and drop it on the sprite.
ASKER
Im not to sure what you mean by this. Could you please explain a bit better please.
Thanks
Thanks
Open a new script member. Paste the code into it. Select the member and in the property inspector click the "script" tab and set it to behavior. Then drag the behavior onto your sprite on the stage.
ASKER
I put the code into a script member and set the property of it to behavior as you said. I then dragged this over the text that i had set up as the hyperlink and it changed the color of the links fine but it wouldnt open the webpage
ASKER
I added this code onto the existing code above but I got an error saying "Script error: name already used on hyperLinkCLicked me, data, range". Was this the correct place to add it?
Looks like you already had a hyperlinkclicked handler. Cna you post your full code?
ASKER
I created a text box and highlighted the data, then went to Window - Inspectors - Text and entered in the website i wanted to go to. I then added the following behavior to my movie so that whenever I clicked on a hyperlink the proper page would open up.
on mouseUP me
url = member("myURL(website)").t ext
if not(url contains "http://") then
url = "http://" & url
end if
goToNetPage(url)
end
I then added the following code that you sugguested to another behavior to set the color of the weblinks but when i attached this to the text boxes i created above the hyperlinks would no longer work but the color could be set:
property spriteNum
property pDefColor
property pVisitedColor
property pMember
global gClickedList
on getPropertyDescriptionList me
p = [:]
p.addProp(#pDefColor, [#format : #color, #default : rgb(255, 0, 0), #comment : "Base Color"])
p.addProp(#pVisitedColor, [#format : #color, #default : rgb(0, 255, 0), #comment : "Visited Color"])
return p
end
on beginSprite me
if gClickedList = void then gClickedList = []
pMember= sprite(spriteNum).member
pMember.usehypertextstyles = 0
pMember.color = rgb(0,0,0)
iHyperlinks = pMember.hyperlinks
repeat with link in iHyperlinks
linkName = pMember.name & "-" & link[1] & "-" & link[2]
me.colorize(link, linkName)
end repeat
sprite(spriteNum).cursor = 0
end
on endSprite me
sprite(spritenum).cursor = 0
end
on mouseWithin me
if sprite(spriteNUm).pointInH yperlink(t he mouseLoc) then
if sprite(spriteNum).cursor <> 280 then
sprite(spriteNum).cursor = 280
end if
else
if sprite(spriteNum).cursor <> 0 then
sprite(spriteNum).cursor = 0
end if
end if
end
on colorize me, link, linkName
if gClickedList.getOne(linkNa me) then
pMember.char[link[1]..link [2]].color = pVisitedCOlor
else
pMember.char[link[1]..link [2]].color = pDefColor
end if
end
on hyperLinkCLicked me, d, link
linkName = pMember.name & "-" & link[1] & "-" & link[2]
if gClickedList.getOne(linkNa me) = 0 then gClickedList.add(linkName)
me.colorize(link, linkName)
end
on getBehaviorDescription me
return "Place on a text member and set the colors for custom hyperlink colors."
end
on mouseUP me
url = member("myURL(website)").t
if not(url contains "http://") then
url = "http://" & url
end if
goToNetPage(url)
end
I then added the following code that you sugguested to another behavior to set the color of the weblinks but when i attached this to the text boxes i created above the hyperlinks would no longer work but the color could be set:
property spriteNum
property pDefColor
property pVisitedColor
property pMember
global gClickedList
on getPropertyDescriptionList
p = [:]
p.addProp(#pDefColor, [#format : #color, #default : rgb(255, 0, 0), #comment : "Base Color"])
p.addProp(#pVisitedColor, [#format : #color, #default : rgb(0, 255, 0), #comment : "Visited Color"])
return p
end
on beginSprite me
if gClickedList = void then gClickedList = []
pMember= sprite(spriteNum).member
pMember.usehypertextstyles
pMember.color = rgb(0,0,0)
iHyperlinks = pMember.hyperlinks
repeat with link in iHyperlinks
linkName = pMember.name & "-" & link[1] & "-" & link[2]
me.colorize(link, linkName)
end repeat
sprite(spriteNum).cursor = 0
end
on endSprite me
sprite(spritenum).cursor = 0
end
on mouseWithin me
if sprite(spriteNUm).pointInH
if sprite(spriteNum).cursor <> 280 then
sprite(spriteNum).cursor = 280
end if
else
if sprite(spriteNum).cursor <> 0 then
sprite(spriteNum).cursor = 0
end if
end if
end
on colorize me, link, linkName
if gClickedList.getOne(linkNa
pMember.char[link[1]..link
else
pMember.char[link[1]..link
end if
end
on hyperLinkCLicked me, d, link
linkName = pMember.name & "-" & link[1] & "-" & link[2]
if gClickedList.getOne(linkNa
me.colorize(link, linkName)
end
on getBehaviorDescription me
return "Place on a text member and set the colors for custom hyperlink colors."
end
Change
on hyperLinkCLicked me, d, link
linkName = pMember.name & "-" & link[1] & "-" & link[2]
if gClickedList.getOne(linkNa me) = 0 then gClickedList.add(linkName)
me.colorize(link, linkName)
end
to ...
on hyperLinkCLicked me, d, link
linkName = pMember.name & "-" & link[1] & "-" & link[2]
if gClickedList.getOne(linkNa me) = 0 then gClickedList.add(linkName)
me.colorize(link, linkName)
url = data
if not(url contains "http://") then
url = "http://" & url
end if
goToNetPage(url)
end
on hyperLinkCLicked me, d, link
linkName = pMember.name & "-" & link[1] & "-" & link[2]
if gClickedList.getOne(linkNa
me.colorize(link, linkName)
end
to ...
on hyperLinkCLicked me, d, link
linkName = pMember.name & "-" & link[1] & "-" & link[2]
if gClickedList.getOne(linkNa
me.colorize(link, linkName)
url = data
if not(url contains "http://") then
url = "http://" & url
end if
goToNetPage(url)
end
ASKER
I made the changes you said and i got the following script error: "Variable used before assigned a value url = data ?"
Change to
url = d
url = d
ASKER
As I said above I set up a button so that when a user enters a web address and clicks the button the user goes to it, if it exists. But if I have only 1 browser window open (The one the program is currently running on this is the one that displays the page therefore exiting the program). Is there anyway around this to ensure that a new web page would be opened therefore not exiting the program.
The original code is:
on mouseUP me
url = memeber("myURL").text
if not(url contains "http://") then
url = "http://" & url
end if
goToNetPage(url)
end
The original code is:
on mouseUP me
url = memeber("myURL").text
if not(url contains "http://") then
url = "http://" & url
end if
goToNetPage(url)
end
goToNetPage(url, "_blank")
That will open a new window.
That will open a new window.
ASKER
Is there any way that you can make the above code work so that when the return key is pressed it goes to the website as well?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.