A Flash Developer Resource Site

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

Thread: hyperlinks in xml data?

  1. #1
    Member
    Join Date
    Oct 2000
    Location
    Los Angeles
    Posts
    71

    hyperlinks in xml data?

    I'm importing some xml data to a site and have a node attribute with an "a href" tag but it seems to stop the flow of the xml data.

    Simple html tags can be put in xml data, yes?
    Last edited by bytemonster; 10-12-2003 at 12:55 AM.
    ---------------
    bytemonster

  2. #2
    Member
    Join Date
    Oct 2000
    Location
    Los Angeles
    Posts
    71
    Somebody? The only way I can seem to import a link from xml to flash is to encode each greater-than, less-than, and quote symbol to the html equivalent. Isn't there a better way to do this? I have a url embedded in a node attribute.
    ---------------
    bytemonster

  3. #3
    Senior Member
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    147
    Good question mate!
    same as mine!

    Im trying to get a link on each seperate image,
    that im importing with xml...

    each pic would be a different link...
    I need to have to links working straight from the xml
    so its easily editable for large amounts of info/pics.

    Anyone help?

  4. #4
    Member
    Join Date
    Oct 2000
    Location
    Los Angeles
    Posts
    71
    c'mon...where are the xml gurus around here?
    ---------------
    bytemonster

  5. #5
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Sorry, not an XML guru, but I did spend the weekend sailing and riding (road bike), so unfortunately I didn't have much time to answer your XML questions.

    Simple html tags should be fine. However they must follow the XML standards, so very old html might have:

    PHP Code:
    <a href=blahblahblah>Link</a
    Which should be:


    PHP Code:
    <a href='blahblahblah'>Link</a
    The quotes make it legal xml. Seeing you will probably have more questions about the XML & HTML I have a example of converting XML to HTML that can be displayed in an text box:

    http://tupps.com/flash/examples/load.../demoText.html

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  6. #6
    Senior Member
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    147
    Thanks Tupps,

    Where about in melbourne are you from?
    Im from sydney!

    Anyway,

    I understand how the ( a href is meant to be .etc )
    But my problem lays with how it fits into my XML...
    with out stuffing up how it also loads my images into the flash.

    I need to get the images in and scrolling,
    and have each image as a link its self,
    and the link has to come from the XML.

    here is the XML i have used now, and the FLA incase you need to put in some actionscript to create a get URL type thing, for each image.

    Thanks heaps mate!

    Aden

  7. #7
    Senior Member
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    147
    SO basically,

    When a pic on the scroller is clicked,
    I want it to load the url of a page,
    where the pic's link, is determined by code
    in the XML doccument, in the same tag as the actual image.

    Making sence?

    Ive seriously got no idea how to make this happen!
    grrrrrr

    Thanks heaps tupps.

  8. #8
    Senior Member
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    147
    anyone?

  9. #9
    i'm looking for a way to do this as well for my web portfolio so when thumbnail pic of a website i've done shows - the user can click on it (or some text) that will link them to that particular site

    anyone have a solution?

    cheers
    alex

  10. #10
    Member
    Join Date
    Oct 2000
    Location
    Los Angeles
    Posts
    71
    I'm still not getting an answer to my question.

    Let's say my xml doc is:

    &lt;?xml version=&quot;1.0&quot; standalone=&quot;no&quot; ?&gt;
    &lt;FILMOGRAPHY&gt;
    &nbsp;&lt;FILM
    &nbsp;&nbsp;title=&quot;&lt;a href='ref/lotr-tt_ref.html' target='_blank'&gt;Dirty Dancing&lt;/a&gt;&quot;
    &nbsp;&nbsp;client=&quot;Artisan&quot;
    &nbsp;&nbsp;project=&quot;Mixing and Mastering in 5.1, 6.1 and 2.0&quot;
    /&gt;
    &lt;/FILMOGRAPHY&gt;

    That doesn't seem to work unless I encode the symbols like this:

    &nbsp;&nbsp;title=&quot;&amp;lt;a href=&amp;quot;ref/lotr-tt_ref.html&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;Dirty Dancing&amp;lt;/a&amp;gt;&quot;

    Also, am I limited to 128 characters in an attribute?

    The whole point is, I'm trying to make it more easily updatable for the client, who knows very basic html

    Am I going to have to convert the attributes into nodes in order to add links or use more than 128 characters?

    Where are the xml gurus on this?
    Last edited by bytemonster; 10-16-2003 at 07:29 PM.
    ---------------
    bytemonster

  11. #11
    Senior Member
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    147
    Its cool guys!

    Some one will help us out soon!
    Tupps is a genious, so im sure he will help us out when he gets a chance!!

    Or some other good citizen of flash kit!!

    thanks,

    Aden!

  12. #12
    Senior Member
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    147
    It think some how ive got to make each image a link, in which then finds the xml and reads the <a href="dfkjhdfjd"></a>
    so when the images is clicked, it loads its appropriate page!
    different to every other image's link!

    i still cant get anyhitng to work!
    if anyone is helping...

    View my attatchent a few posts up!

    thanks

  13. #13
    Senior Member
    Join Date
    Jun 2001
    Posts
    150
    i've also been stuck on this for a while and i'm just really, really frustrated. if xml is so great, why is something like a simple unidirectional link so bloody difficult??

    luke, i've looked at your example, looked at the xml doc and the .fla, and i guess that i'm just not advanced enough in xml to make this work.

    basically my question is: what do i have to do to my actionscript to make the xml display correctly?

    here's a concrete example: i have a series of images that load at runtime. to the right of the images i have descriptions; underneath, i have copyright information and want to be able to link to the photographers' sites. so my xml doc looks like
    PHP Code:
    <?xml version = "1.0"?>
      <Images> 
        <ImageNode jpegURL="images/misc_01.jpg" copyright="photo © Martin Parr">This is a photo of whatever.</ImageNode>
    .
    .
    .
    </Images>
    and in my .fla i have
    Code:
    miscXML = new XML();
    miscXML.onLoad = displayImages;
    miscXML.load("misc.xml");
    miscXML.ignoreWhite = true;
    
    function displayImages(success) {
    	if (success == true) {
    			rootNode = miscXML.firstChild;
    			totalImages = rootNode.childNodes.length;
    			firstImageNode = rootNode.firstChild;
    			currentImageNode = firstImageNode;
    			currentIndex = 1;
    			updateImage(firstImageNode);
    
    	}
    }
    
    //you probably don't need to know the following, but i'll include it just in case...
    
    function updateImage(newImageNode) {
    	imagePath = newImageNode.attributes.jpegURL;
    	copyright = newImageNode.attributes.copyright;
    	caption = newImageNode.firstChild.nodeValue;
    	
    	loadMovie(imagePath, targetClip);
    }
    
    next_btn.onRelease = function() {
    	nextImageNode = currentImageNode.nextSibling;
    	if (nextImageNode == null) {
    		break;
    	} else {
    		currentIndex++;
    		updateImage(nextImageNode);
    		currentImageNode = nextImageNode;
    	}
    };
    
    back_btn.onRelease = function() {
    	previousImageNode = currentImageNode.previousSibling;
    	if (previousImageNode == null) {
    		break;
    	} else {
    		currentIndex--;
    		currentImageNode = previousImageNode;
    		updateImage(previousImageNode);
    	}
    };
    i have tried all sorts of things and can't get anything to work. please, please help!

  14. #14
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    OK, seeing there are so many questions in this thread, I will answer them with individual posts.

    For ByteMonster, it is not legal to have XML tags in your attributes. Two options are available, one you have already discovered which is to URL encode all the text.

    The other would be to move the attributes into nodes (if you wanted a 'proper' way that XML purists would believe in).

    eg:

    PHP Code:
      <FILM
      client
    ="Artisan"
      
    project="Mixing and Mastering in 5.1, 6.1 and 2.0">
    <
    TITLE><a href='ref/lotr-tt_ref.html' target='_blank'>Dirty Dancing</a></TITLE>
    </
    FILM
    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  15. #15
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Bodoni,

    With your problem, I am guessing that you are not getting the node you think you are getting as the first node.

    As a starting point I would place a trace statement in the updateImage function, tracing the newImageNode

    trace(newImageNode)

    This should print out the node that you are receiving and you can verify that your input data is correct.

    If that is correct I would then check to make sure all your variables read from attributes are being set (trace statements again).

    If all of that doesn't work I would need to see your flash file.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  16. #16
    Senior Member
    Join Date
    Jun 2001
    Posts
    150
    wow, luke, thanks for responding so quickly and specifically.

    it's going to take me a few minutes to digest and then try your suggestions.

    a couple of thoughts occur to me: (a) the xml code/actionscript that i posted currently works just fine. (sorry if i wasn't clear.) it does what i want it to do. however it fails to work when i try to insert an anchor tag. part of the problem may have been that, as you can see, i set up "copyright" as an attribute, and then tried to use the link within the attribute. if i read your response to bytemonster correctly, that's not a legal move. but i also tried to use the anchor tag within the imageNode, and that didn't work either.

    (b) is there any sort of hard and fast rule that makes sense and that i could read somewhere that would say: "here's how to insert a simple unidirectional link into an xml document" and "here's how to set it up in your .fla so that it will work."

    how difficult can this be? well very, i guess.


  17. #17
    Member
    Join Date
    Oct 2000
    Location
    Los Angeles
    Posts
    71
    That's what I thought, tupps, but for some reason, I get the FONT tag workng but not the A HREF tag. Also, any info after this line is cut off.

    PHP Code:
        <FILM>
            <
    TITLE><font color="#0000FF"><a_href="ref/lotr-tt_ref.html"_target="_blank">About Schmidt</a></font></TITLE>
            <
    CLIENT>New Line Cinema</CLIENT>
            <
    PROJECT>Mixing and Mastering in 5.1 2.0</PROJECT>
            </
    FILM>
        <
    FILM
    Am I doing something wrong? Do I have to add something to my code?
    ---------------
    bytemonster

  18. #18
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    ByteMonster:

    Is there any reason that there is an underscore in your < a href tag? Also in front of target as well?

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  19. #19
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Bodoni

    For hard and fast rules:

    1) Anything in attributes must be either straight text, or you could urlencode the text and use that. Flash has a escape and a unescape function that will handle urlencoded text.

    2) In a node there are two ways to add HTML. One is to use a CDATA tag, which the XML parser will basically ignore and give you in its entirity. Otherwise you have to make sure that everything is valid XML.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  20. #20
    Member
    Join Date
    Oct 2000
    Location
    Los Angeles
    Posts
    71
    thanks tupps...that was a screwup...it's working now...except for that pesky 128 character problem.
    ---------------
    bytemonster

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