-
hyperlinks in XML...?
i'm trying to add some hyperlinks to the text within the msg tags; please can someone tell me how to do this.... (with the link opening in a new browser window):
PHP Code:
<?xml version="1.0"?>
<diary>
<cal yearID="2006" monthID="0">
<date id="1">
<msg>an event</msg>
</date>
<date id="17">
<msg>another event</msg>
</date>
</cal>
</diary>
cheers.
-
this is where i'm up to now:
PHP Code:
<?xml version="1.0"?>
<diary xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple">
<cal yearID="2006" monthID="1">
<date id="1">
<msg>an event</msg>
</date>
<date id="10">
<msg>another big event</msg>
</date>
<date id="12">
<msg>event</msg>
</date>
<date id="25">
<msg>another event</msg>
</date>
</cal>
<cal yearID="2006" monthID="0">
<date id="27">
<msg>new event..... <a xlink:type="simple" href="www.google.co.uk"> ...link... </a> </msg>
</date>
<date id="28">
<msg>this is going to be a really funky event</msg>
</date>
</cal>
</diary>
...but this still doesn't work...
-
-
thanks Luke
but what i don't get is that there is no code at all in the XML file?? all the code is in the Flash file?
....but what i also don't understand is what is identifying the word "link" to be a link, and where's the http address etc ??
-
<msg><![CDATA[Welcome to <a href='www.yahoo.com'>YAHOO</a>Cheers]]></msg>
Populate this as htmlText in a Flash dynamic textfield with html set to true[/QUOTE]
-
... atrangee... superb!! thanks
at first i still had some of my old message straight after the <msg> tags, and it didn't work, nothing appeared... when i inserted the code exactly as you've written it above... works a treat! and i've noticed i can add further HTML tags to underline the links etc... i owe you a pint!!
-
So what did you end up using to make this all work out...
I use the CDATA solution and It does not work... are you using Luke's solution in conjunction ?
Oh ya... I am using flash 8 too if that makes any difference.
Adam
-
I got it working.. as a side not, since I have been working on this all day and the solution made me feel like an idiot.. In the AS when you are setting the text. You need to be sure you pass the nodeValue... I was doing this:
myTxt.txt = xmlNode.firstChild
That was wrong.. It was rendering the text, but it would not do the link... then I did this:
myTxt = xmlNode.firstChild.nodeValue
and that did the trick.
-
hi logix
sorry i didn't reply... my email notifications don't work, so i have to manually check my subscriptions (i've informed the moderators but no response as yet)...
but glad to hear you got it working!!
-
If anyone could help me out, please. I don't understand how to make links in a xml. And I've read through a lot of post and some of the links here. Most of them used an older flash player and thus didn't work with mine. So far it has been quite easy to work in xml and Flash but I'm completely lost in thi case. Here's my code for my xml file. I use flashplayer 7 and as 2.0:
Code:
stop();
container.stop();
var timeline = this;
System.useCodepage = true;
var loader2:XML = new XML();
loader2.load("files/Filer/Flash/overskrift.xml");
loader2.ignoreWhite = true;
loader2.onLoad = function() {
_global.rod2 = this.firstChild.childNodes;
var antalXML:Number = rod2.length-1;
setter(0);
};
setter = function (id) {
timeline.container_overskrift.overskrift.text = rod2[id].firstChild.firstChild.nodeValue;
timeline.container_overskrift.overskrift.autoSize = true;
timeline.container_overskrift.overskrift.multiline = true;
};
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}
var loader:XML = new XML();
loader.load("files/Filer/Flash/tekst.xml");
loader.ignoreWhite = true;
loader.onLoad = function() {
_global.rod = this.firstChild.childNodes;
var antalXML:Number = rod.length-1;
for (i=0; i<1; i++) {
var randomNumber:Number = randRange(0, antalXML);
}
setter2(randomNumber);
};
setter2 = function (id) {
timeline.container.holder.tekst1.text = rod[id].firstChild.firstChild.nodeValue;
timeline.container.holder.tekst1.multiline = true;
timeline.container.holder.tekst2.text = rod[id].firstChild.nextSibling.firstChild;
timeline.container.holder.tekst2.multiline = true;
container.play();
_global.antal = id;
};
Regards
Michael
-
hi fahlsten... i don't know too much about XML; this is the first time i've used it... but i found atrangees solution worked for me (using the ![CDATA[ code in the XML file itself), i didn't need to touch the Flash AS.
you may need to render the dynamic text in the Flash movie as HTML, i'm not sure...
ric
-
Hello Ric and thanks for your reply. How do I use tha CDATA? I tried but I must have done something wrong.
Regards
michael
-
try this:
<msg><![CDATA[blah blah blah text, and now take a look at this <u><a href='http://www.domain.co.uk' target='_blank'>website</a></u> this week]]>
</msg>
-
Hello again. When I try that, the output is:
blah blah blah text, and now take a look at this <u><a href='http://www.domain.co.uk' target='_blank'>website</a></u> this week
The same happened when I tried before. My textfield renders text as HTML and in my code I use:
textfield.html = true;
What am I doing wrong??
Regards
Michael
-
sorry mate! i'm not very good at this stuff!! it's the first time i've used it and luckily it worked for me... hopefully one of the others in this thread will help... or anyone else who reads this..... good luck
-
Ok, thanks for trying :thumbsup: .
Hopefully someone will explain it. It's probably just something simple I didn't put in the code.
-
Now it's working!
Finally :)
-
Fahlsten, how did you get this to work? I'm struggling with hyperlinking XML into flash. I've tried everything from CADTA to XLink and I feel I'm probably doin something very wrong.
-
Hello tcheese.
I'll just have a look into it later today and explain how I did it. I'll also send a fla, so you'll see how it's working
-
-
1 Attachment(s)
Ok, I've included a simple version of the xml I made. Now there's only the textfield with the link in it. You might see some code leftover from the original file, but I've managed to remove most of it.
Have you used xml before in flash? If not, things might seem a bit difficult but just let me know and I'll try to explain.
Regards
Michael
-
Thanks so much! I wrote mine completely differently:
http://board.flashkit.com/board/showthread.php?t=687846
I just keep running into a bunch of different ways to do it from Xlink to CDATA and none seem to be working for me. I've used XML before in Flash, but it's usually been pretty basic stuff. I'm trying to see how I can get your example to work in my file and/or vice versa. Thanks again!
-
Yeah, I can see that. Hopefully you'll be able to use the file I've included. If not, just let me know.
Good luck
Michael
-
is there a way to make a link in XML by using components rather than a dynamic text box?
I'm using flash 8, and the XML CONNECTOR to call my xml file and bind all my components.
I've created an employee database that has:
1 list box
2 text area components
in the list box, names are generated from the xml...
once you click on a name, the 2 text area components are populated
With in these text area components are the populated fields: 'website' and 'email'
right now they are populated in the format: http://www.blah5645blah.com / info@blah4535blah.com
The boxes populate, but I dont know how to make them a link.
Does it require me to add actionscript and/or a hyperlink cell renderer? or is the solution within the XML file?
also...these text area components both have the HTML option set to 'TRUE'
-----
-
Another followup for those who have trouble:
I was trying all of these methods to no avail for an hour or so to no avail. but once I turned off font embedding worked like a charm.
-
I sorta cheated....
My BLOATED xml - I called it citysearch.xml - (Thanks to Citysearch)
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE ads PUBLIC "" "http://pfp.citysearch.com/schema/partner/1.0.0/CitysearchPFPResults.dtd"><ads xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://pfp.citysearch.com/schema/partner/1.0.0/CitysearchPFPResults.xsd"> <ad rank="1" address_line_1="230 N San Fernando Blvd" city="Burbank" state="CA" postal_code="91502" image_link="http://a1004.g.akamaitech.net/7/1004/33/d3eac684cd2687/images.citysearch.com/sys/ad_images/e2/7c/V-LOSCA-55078677_ID134890_pfp_image.gif" cpc="0" > <urls> <url type="business_name" text="Gourmet 88" click_url="http://pfp.citysearch.com/url/?aid=2032104&ltid=28&eid=314046&rank=1 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="tagline" text="10th Century Chinese Cuisine With A Californian Twist" click_url="http://pfp.citysearch.com/url/?aid=2032104&ltid=28&eid=314046&rank=1 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="profile" text="Overview" click_url="http://pfp.citysearch.com/url/?aid=2032104&ltid=profile&eid=314046&r ank=1&atid=35&total_ads=3&rmid=1&b rand=synd_test" ></url> <url type="ad_bullet_1" text="Extraordinary Service" click_url="http://pfp.citysearch.com/url/?aid=2032104&ltid=25&eid=314046&rank=1 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="ad_bullet_2" text="Take Out & Delivery" click_url="http://pfp.citysearch.com/url/?aid=2032104&ltid=26&eid=314046&rank=1 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="ad_bullet_3" text="Delicious Dishes" click_url="http://pfp.citysearch.com/url/?aid=2032104&ltid=27&eid=314046&rank=1 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="editorial_tagline" ></url> <url type="website_link" text="www.gourmet88.com" click_url="http://pfp.citysearch.com/url/?aid=2032104&ltid=30&eid=314046&rank=1 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="offer" ></url> </urls> </ad> <ad rank="2" address_line_1="1333 3RD St Promenade" city="Santa Monica" state="CA" postal_code="90401" image_link="http://a1932.g.akamaitech.net/7/1932/33/7a1708a6bd2778/images.citysearch.com/sys/ad_images/64/5c/V-LOSCA-55051635_ID71837_pfp_image.gif" cpc="0" > <urls> <url type="business_name" text="Yangtze Restaurant" click_url="http://pfp.citysearch.com/url/?aid=961977&ltid=28&eid=157680&rank=2& amp;atid=35&total_ads=3&rmid=1&brand=s ynd_test" ></url> <url type="tagline" text="Authentic Thai-Chinese Cuisine &amp; Sushi Bar" click_url="http://pfp.citysearch.com/url/?aid=961977&ltid=28&eid=157680&rank=2& amp;atid=35&total_ads=3&rmid=1&brand=s ynd_test" ></url> <url type="profile" text="Overview" click_url="http://pfp.citysearch.com/url/?aid=961977&ltid=profile&eid=157680&ra nk=2&atid=35&total_ads=3&rmid=1&br and=synd_test" ></url> <url type="ad_bullet_1" ></url> <url type="ad_bullet_2" ></url> <url type="ad_bullet_3" ></url> <url type="editorial_tagline" text="Third Street shoppers take a break at this contemporary Chinese, Thai and Japanese restaurant. Half-priced sushi at the bar, free delivery." click_url="http://pfp.citysearch.com/url/?aid=961977&ltid=36&eid=157680&rank=2& amp;atid=35&total_ads=3&rmid=1&brand=s ynd_test" ></url> <url type="website_link" text="www.yangtzerestaurant.com" click_url="http://pfp.citysearch.com/url/?aid=961977&ltid=30&eid=157680&rank=2& amp;atid=35&total_ads=3&rmid=1&brand=s ynd_test" ></url> <url type="offer" ></url> </urls> </ad> <ad rank="3" address_line_1="3221 Donald Douglas Loop S" city="Santa Monica" state="CA" postal_code="90405" image_link="http://a620.g.akamaitech.net/7/620/33/88f04dce3848f1/images.citysearch.com/sys/ad_images/47/74/V-LOSCA-55082840_ID146981_pfp_image.gif" cpc="0" > <urls> <url type="business_name" text="TYPHOON" click_url="http://pfp.citysearch.com/url/?aid=2089272&ltid=28&eid=163661&rank=3 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="tagline" text="L.A.'s Premier Pan-Asian Restaurant" click_url="http://pfp.citysearch.com/url/?aid=2089272&ltid=28&eid=163661&rank=3 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="profile" text="Overview" click_url="http://pfp.citysearch.com/url/?aid=2089272&ltid=profile&eid=163661&r ank=3&atid=35&total_ads=3&rmid=1&b rand=synd_test" ></url> <url type="ad_bullet_1" text="Wedding or other Special Event" click_url="http://pfp.citysearch.com/url/?aid=2089272&ltid=25&eid=163661&rank=3 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="ad_bullet_2" text="SUNDAY BRUNCH" click_url="http://pfp.citysearch.com/url/?aid=2089272&ltid=26&eid=163661&rank=3 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="ad_bullet_3" text="Enjoy breathtaking views" click_url="http://pfp.citysearch.com/url/?aid=2089272&ltid=27&eid=163661&rank=3 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="editorial_tagline" text="Fried insects and flying machines invert nature at this Santa Monica Airport roost." click_url="http://pfp.citysearch.com/url/?aid=2089272&ltid=36&eid=163661&rank=3 &atid=35&total_ads=3&rmid=1&brand= synd_test" ></url> <url type="website_link" ></url> <url type="offer" ></url> </urls> </ad></ads>
Actionscript I modded and made up too:
function loadXML(loaded) {
if (loaded) {
_root.business1 = this.firstChild.childNodes[0].childNodes[0].childNodes[0].attributes.text;
_root.tagline1 = this.firstChild.childNodes[0].childNodes[0].childNodes[1].attributes.text;
_root.location1 = this.firstChild.childNodes[0].childNodes[0].childNodes[1].attributes.click_url;
_root.business2 = this.firstChild.childNodes[1].childNodes[0].childNodes[0].attributes.text;
_root.tagline2 = this.firstChild.childNodes[1].childNodes[0].childNodes[1].attributes.text;
_root.location2 = this.firstChild.childNodes[1].childNodes[0].childNodes[1].attributes.click_url;
_root.business3 = this.firstChild.childNodes[2].childNodes[0].childNodes[0].attributes.text;
_root.tagline3 = this.firstChild.childNodes[2].childNodes[0].childNodes[1].attributes.text;
_root.location3 = this.firstChild.childNodes[2].childNodes[0].childNodes[1].attributes.click_url;
biz1.text = _root.business1;
tag1.text = _root.tagline1;
url1.text = _root.location1;
biz2.text = _root.business2;
tag2.text = _root.tagline2;
url2.text = _root.location2;
biz3.text = _root.business3;
tag3.text = _root.tagline3;
url3.text = _root.location3;
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("citysearch.xml");
THEN I MADE BUTTONS TO GO ON TOP WITH ALPHA OF 0
on (release) {
getURL(_root.location1, "_blank");
}
on (release) {
getURL(_root.location2, "_blank");
}
on (release) {
getURL(_root.location3, "_blank");
}
Just make sure you turn on EXPRESSION in the getURL or it won't work. :yikes:
-
Does any one have a working fla. and xml file that shows how to create hyperlinks in the xml file? That would be grand and unquestionably appreciated...
-
1 Attachment(s)
I can't upload an XML file so you'll have to use this link:
http://www.chron.com/content/chronic.../johnmayer.xml
FLA is attached.
-
I got it working baby!! thanx 2 Chris Sehorn... I owe u 1 big-time.... :thumbsup:
-
Glad it worked out :thumbsup: :thumbsup: