To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Display Modes
Old 06-17-2006, 11:20 PM   #1
roilove
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>
roilove is offline   Reply With Quote
Old 06-18-2006, 12:14 AM   #2
Smilev
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");
Smilev is offline   Reply With Quote
Old 06-18-2006, 01:28 AM   #3
roilove
Junior Member
 
Join Date: Jun 2006
Posts: 5
Thank You

How I enable html? is that right?

newPiece.desc_txt.htmlText = true;
roilove is offline   Reply With Quote
Old 06-18-2006, 03:12 AM   #4
Smilev
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");
Smilev is offline   Reply With Quote
Old 06-18-2006, 03:14 AM   #5
Smilev
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");
Smilev is offline   Reply With Quote
Old 06-18-2006, 01:46 PM   #6
roilove
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
roilove is offline   Reply With Quote
Old 06-18-2006, 09:41 PM   #7
roilove
Junior Member
 
Join Date: Jun 2006
Posts: 5
can you help me out?
roilove is offline   Reply With Quote
Old 06-19-2006, 03:47 AM   #8
Smilev
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");
Smilev is offline   Reply With Quote
Old 06-19-2006, 10:09 AM   #9
roilove
Junior Member
 
Join Date: Jun 2006
Posts: 5
wow it's work Thank you! Thank you!
roilove is offline   Reply With Quote
Old 10-24-2006, 04:54 PM   #10
axxo
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
axxo is offline   Reply With Quote
Old 10-25-2006, 04:21 AM   #11
Smilev
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");
Smilev is offline   Reply With Quote
Old 10-26-2006, 07:39 AM   #12
axxo
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!
axxo is offline   Reply With Quote
Old 11-06-2006, 06:48 PM   #13
axxo
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
axxo is offline   Reply With Quote
Old 11-07-2006, 09:30 AM   #14
Smilev
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");
Smilev is offline   Reply With Quote
Old 11-07-2006, 10:24 AM   #15
axxo
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?
axxo is offline   Reply With Quote
Old 11-07-2006, 11:07 AM   #16
Smilev
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");
Smilev is offline   Reply With Quote
Old 11-07-2006, 11:10 AM   #17
axxo
Junior Member
 
Join Date: Oct 2006
Posts: 17
ok, i zipped all together
www.spazio.org/limited/v2.zip

thank you
axxo is offline   Reply With Quote
Old 11-08-2006, 04:34 AM   #18
Smilev
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");
Smilev is offline   Reply With Quote
Old 11-08-2006, 04:44 AM   #19
Smilev
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");
Smilev is offline   Reply With Quote
Old 11-09-2006, 03:09 PM   #20
axxo
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
axxo is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:22 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.