A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 30

Thread: hyperlinks in XML...?

  1. #1
    Member
    Join Date
    Feb 2005
    Location
    manchester, england
    Posts
    98

    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.

  2. #2
    Member
    Join Date
    Feb 2005
    Location
    manchester, england
    Posts
    98
    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...

  3. #3
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  4. #4
    Member
    Join Date
    Feb 2005
    Location
    manchester, england
    Posts
    98
    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 ??

  5. #5
    Junior Member
    Join Date
    Dec 2005
    Posts
    4
    &lt;msg&gt;&lt;![CDATA[Welcome to &lt;a href='www.yahoo.com'&gt;YAHOO&lt;/a&gt;Cheers]]&gt;&lt;/msg&gt;


    Populate this as htmlText in a Flash dynamic textfield with html set to true[/QUOTE]

  6. #6
    Member
    Join Date
    Feb 2005
    Location
    manchester, england
    Posts
    98
    ... 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!!

  7. #7
    Junior Member
    Join Date
    Jun 2005
    Posts
    3
    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

  8. #8
    Junior Member
    Join Date
    Jun 2005
    Posts
    3
    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.

  9. #9
    Member
    Join Date
    Feb 2005
    Location
    manchester, england
    Posts
    98
    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!!

  10. #10
    Senior Member
    Join Date
    Jan 2001
    Location
    Copenhagen
    Posts
    192
    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

  11. #11
    Member
    Join Date
    Feb 2005
    Location
    manchester, england
    Posts
    98
    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

  12. #12
    Senior Member
    Join Date
    Jan 2001
    Location
    Copenhagen
    Posts
    192
    Hello Ric and thanks for your reply. How do I use tha CDATA? I tried but I must have done something wrong.

    Regards
    michael

  13. #13
    Member
    Join Date
    Feb 2005
    Location
    manchester, england
    Posts
    98
    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>

  14. #14
    Senior Member
    Join Date
    Jan 2001
    Location
    Copenhagen
    Posts
    192
    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

  15. #15
    Member
    Join Date
    Feb 2005
    Location
    manchester, england
    Posts
    98
    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

  16. #16
    Senior Member
    Join Date
    Jan 2001
    Location
    Copenhagen
    Posts
    192
    Ok, thanks for trying .
    Hopefully someone will explain it. It's probably just something simple I didn't put in the code.

  17. #17
    Senior Member
    Join Date
    Jan 2001
    Location
    Copenhagen
    Posts
    192
    Now it's working!
    Finally

  18. #18
    Junior Member
    Join Date
    Mar 2006
    Posts
    12
    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.

  19. #19
    Senior Member
    Join Date
    Jan 2001
    Location
    Copenhagen
    Posts
    192
    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

  20. #20
    Junior Member
    Join Date
    Mar 2006
    Posts
    12
    Thanks so much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center