|
|
|
#1 |
|
Junior Member
Join Date: Jun 2006
Posts: 5
|
hyperlinks in XML
Hi,
I was reading this post http://board.flashkit.com/board/show...=671551&page=1 I had the same question, and it's hard for me to solve my problem with my gallery. It works fine, all I need is someone to help me out to include links in my XML file. I want the link to be at the <desc>text</desc>. The link should be the word "text". The gallery is built in Flash and loading XML with the photos. I would really appreciate any help. here are my files: 1. FLASH script: myXML = new XML(); myXML.ignoreWhite = true; myXML.onLoad = function(ok) { if (ok) { //process data allGalleryData = this.firstChild.childNodes; for (i=0; i<allGalleryData.length; i++) { newPiece = sliderHolder_mc.slider_mc.attachMovie('template', 'piece'+i, i); newPiece._x = i*newPiece._width; newPiece.heading_txt.text = allGalleryData[i].firstChild.firstChild; newPiece.desc_txt.text = allGalleryData[i].firstChild.nextSibling.firstChild; newPiece.load_btn.imageName = allGalleryData[i].firstChild.nextSibling.nextSibling.firstChild; newPiece.holder_mc.loadMovie('portfolio/print/'+newPiece.load_btn.imageName); newPiece.load_btn.onRelease=function(){ bigImage_mc.loadMovie('images/'+this.imageName) } //trace(allGalleryData[i].firstChild.firstChild); newBut = _root.attachMovie('numTemplate', 'num'+i, i); newBut._y = sliderHolder_mc._y+sliderHolder_mc._height-15; newBut._x = (i*newBut._width)+sliderHolder_mc._x+15; newBut.myNum = i; newBut.num_txt.text = i+1; newBut.onRelease = function() { targX = 0-(this.myNum*360); }; } targX = 0; sliderHolder_mc.slider_mc.onEnterFrame = function() { this._x -= (this._x-targX)/2; }; } else { trace('what file?'); } }; myXML.load('xml/print.xml'); --------------------------------------------------------------------- and the 2. XML file: <?xml version="1.0" encoding="iso-8859-1"?> <gallery heading="Photography"> <piece> <heading>Piece 1</heading> <desc>text</desc> <image>1.jpg</image> </piece> <piece> <heading>Piece 2</heading> <desc>text</desc> <image>2.jpg</image> </piece> </gallery> |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: May 2002
Posts: 987
|
You've got the answer in the thread you point out ...anway try this.
newPiece.desc_txt.htmlText = allGalleryData[i].firstChild.nextSibling.firstChild; // do not forget to enable the textfield to render the text as html then in the xml file : <?xml version="1.0" encoding="iso-8859-1"?> <gallery heading="Photography"> <piece> <heading>Piece 1</heading> <desc><![CDATA[<a href='http://www.yourUrlGoesHere.com' target='_blank'>text</a>]]></desc> <image>1.jpg</image> </piece> <piece> <heading>Piece 2</heading> <desc><![CDATA[<a href='http://www.yourUrlGoesHere.com' target='_blank'>text</a>]]></desc> <image>2.jpg</image> </piece> </gallery>
__________________
while (2+2 == 4) { drink ("bourbon"); } gotoAndStop("bed"); |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jun 2006
Posts: 5
|
Thank You
How I enable html? is that right? newPiece.desc_txt.htmlText = true; |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: May 2002
Posts: 987
|
Yes, that's right. Or in authoring mode, when the textfield is selected, in the properties panel click the little button with pointy brackets "<> "
__________________
while (2+2 == 4) { drink ("bourbon"); } gotoAndStop("bed"); |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: May 2002
Posts: 987
|
err... sorry .. it is not right. correct is
newPiece.desc_txt.html = true;
__________________
while (2+2 == 4) { drink ("bourbon"); } gotoAndStop("bed"); |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jun 2006
Posts: 5
|
Thank's but still it's not working:
here is what I included in flash: I enabled the text field as html <> in flash. and this is the script: myXML = new XML(); myXML.ignoreWhite = true; myXML.onLoad = function(ok) { if (ok) { //process data allGalleryData = this.firstChild.childNodes; for (i=0; i<allGalleryData.length; i++) { newPiece = sliderHolder_mc.slider_mc.attachMovie('template', 'piece'+i, i); newPiece._x = i*newPiece._width; newPiece.heading_txt.text = allGalleryData[i].firstChild.firstChild; newPiece.desc_txt.htmlText = allGalleryData[i].firstChild.nextSibling.firstChild; newPiece.load_btn.imageName = allGalleryData[i].firstChild.nextSibling.nextSibling.firstChild; newPiece.holder_mc.loadMovie('portfolio/Identity/'+newPiece.load_btn.imageName); newPiece.load_btn.onRelease=function(){ bigImage_mc.loadMovie('images/'+this.imageName) } //trace(allGalleryData[i].firstChild.firstChild); newBut = _root.attachMovie('numTemplate', 'num'+i, i); newBut._y = sliderHolder_mc._y+sliderHolder_mc._height-15; newBut._x = (i*newBut._width)+sliderHolder_mc._x+15; newBut.myNum = i; newBut.num_txt.text = i+1; newBut.onRelease = function() { targX = 0-(this.myNum*360); }; } targX = 0; sliderHolder_mc.slider_mc.onEnterFrame = function() { this._x -= (this._x-targX)/2; }; } else { trace('what file?'); } }; myXML.load('xml/identity.xml'); __________________________________________________ ___________ I also added your script to the xml file as you point out (copy paste it) <?xml version="1.0" encoding="iso-8859-1"?> <gallery heading="Photography"> <piece> <heading>Piece 1</heading> <desc><![CDATA[<a href='http://www.yourUrlGoesHere.com' target='_blank'>text</a>]]></desc> <image>1.jpg</image> </piece> <piece> <heading>Piece 2</heading> <desc><![CDATA[<a href='http://www.yourUrlGoesHere.com' target='_blank'>text</a>]]></desc> <image>2.jpg</image> </piece> </gallery> I need help again...Thank's |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Jun 2006
Posts: 5
|
can you help me out?
|
|
|
|
|
|
#8 |
|
Senior Member
Join Date: May 2002
Posts: 987
|
Hmm .. this xml worked for me
.... <piece> <heading>Piece 1</heading> <desc><a href="http://www.yourUrlGoesHere.com" target="_blank">text</a></desc> <image>1.jpg</image> </piece> .... the AS is fine.
__________________
while (2+2 == 4) { drink ("bourbon"); } gotoAndStop("bed"); |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Jun 2006
Posts: 5
|
wow it's work Thank you! Thank you!
|
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Oct 2006
Posts: 17
|
hello!
i got to the same point and everything works fine. now i have a question: would it be possible to have more than one link in between the same <desc></desc>? i tried to have a short text with some links in it, like the following: <desc>hello, I'd like to <a href="http://www.somewhere.com target="_blank">"have</a> more than <a href="http://www.somewherelse.com target="_blank">one</a> link</desc> like that it stops readin when the first tag begins,... why?? could you help me? thank you so much |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: May 2002
Posts: 987
|
Because the xml parser doesnt see text between the <desc></desc> tags like a Text node but as an Element node (see nodeType in Flash Help)
So you should walk the child nodes of the desc node to get the whole text then concate it and assign it to variable or text field.
__________________
while (2+2 == 4) { drink ("bourbon"); } gotoAndStop("bed"); |
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Oct 2006
Posts: 17
|
oops, sorry for the late answer,
anyway thank you very much, now i found a way to make it work! |
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Oct 2006
Posts: 17
|
Hello Smilev,
sorry if i'm bothering you again but now i have this issue: even if i encode my xml file as UTF-8 when i want to display unusual characters (italians) such è or others the browser substitures them with weird stuff as you can see at www.spazio.org/limited/indexx.html and the xml file is www.spazio.org/limited/xml/home.xml here i paste the actioscript myXML = new XML(); myXML.ignoreWhite = true; myXML.onLoad = function(ok) { if (ok) { //process data allGalleryData = this.firstChild.childNodes; for (i=0; i<allGalleryData.length; i++) { newPiece = sliderHolder_mc.slider_mc.attachMovie('template', 'piece'+i, i); newPiece._y = i*newPiece._height; newPiece.title_txt.htmlText = allGalleryData[i].firstChild.firstChild.nodeValue; newPiece.it_txt.htmlText = allGalleryData[i].firstChild.nextSibling.firstChild.nodeValue; newPiece.en_txt.htmlText = allGalleryData[i].firstChild.nextSibling.nextSibling.firstChild.nod eValue; newPiece.load_btn.imageName = allGalleryData[i].firstChild.nextSibling.nextSibling.nextSibling.fi rstChild; newPiece.holder_mc.loadMovie('images/'+newPiece.load_btn.imageName); newPiece.load_btn.onRelease=function(){ bigImage_mc.loadMovie('images/'+this.imageName) } //trace(allGalleryData[i].firstChild.firstChild); newBut = _root.toglieresevuoiilnumero.home.attachMovie('num Template', 'num'+i, i); newBut._y = (i*newBut._height)+sliderHolder_mc._y; newBut._x = +300; newBut.myNum = i; newBut.num_txt.text = i+1; newBut.onRelease = function() { targy = 0-(this.myNum*122); }; } targy = 0; sliderHolder_mc.slider_mc.onEnterFrame = function() { this._y -= (this._y-targy)/5; }; } else { trace('what file?'); } }; myXML.load('xml/home.xml'); could you help me? this is driving me mad thank you! a |
|
|
|
|
|
#14 |
|
Senior Member
Join Date: May 2002
Posts: 987
|
You have to not just put the encoding=utf-8 but also save the file in utf-8. Open it in Notepad. Choose File/Save As and choose utf-8 for the encoding. Then edit it and save it again.
__________________
while (2+2 == 4) { drink ("bourbon"); } gotoAndStop("bed"); |
|
|
|
|
|
#15 |
|
Junior Member
Join Date: Oct 2006
Posts: 17
|
i did it, i saved it with simple text in the way you told me (encoding option=utf-8)
but is still wrong. do you know something else i can try? |
|
|
|
|
|
#16 |
|
Senior Member
Join Date: May 2002
Posts: 987
|
post your fla + xml file so I can check if you like.
__________________
while (2+2 == 4) { drink ("bourbon"); } gotoAndStop("bed"); |
|
|
|
|
|
#17 |
|
Junior Member
Join Date: Oct 2006
Posts: 17
|
|
|
|
|
|
|
#18 |
|
Senior Member
Join Date: May 2002
Posts: 987
|
I dont know ... it looks perfectly ok on my comp. Do you want a screen capture?
__________________
while (2+2 == 4) { drink ("bourbon"); } gotoAndStop("bed"); |
|
|
|
|
|
#19 |
|
Senior Member
Join Date: May 2002
Posts: 987
|
Ohh, but you haven't embeded all characters! The unusual characters are not included in the basic latin charset. You have to include any of the extended Latin versions (scroll futher down). Also make sure, the font you are using is unicode. Not all fonts are unicode or have all the characters.
__________________
while (2+2 == 4) { drink ("bourbon"); } gotoAndStop("bed"); |
|
|
|
|
|
#20 |
|
Junior Member
Join Date: Oct 2006
Posts: 17
|
yes it looks perfect also on my computer, but once i put it online
it mess with those special characters. now i embedded extended latin set (500 characters), and i also opened the font in one font software in order to exporte it as unicode: nothing, it still doesn't work (in the link i sent you it is working, but just because i placed not dynamic txt in there) if you want to give up i 'd understand you, it is really annoyng i don't know what to do |
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|