Results 1 to 5 of 5

Thread: Adding Hyperlink to text inputed by XML? Stylesheets?

  1. #1
    Join Date
    Mar 2008
    Posts
    46
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Adding Hyperlink to text inputed by XML? Stylesheets?

    Hello, I have a site that is using XML to display text and images.
    Here is the AS 2 code I am using in flash to display text:
    stop();
    my_xml = new XML();
    my_xml.load("xml/spa_text_galleries.xml");
    my_xml.onLoad = my_function;
    my_xml.ignoreWhite = 1;

    function my_function() {
    tours_mc.tours.text = my_xml.firstChild.childNodes[0].attributes.body_name;
    }

    Here is a shortened example of the XML file I am using:
    <?xml version="1.0" encoding= "UTF-8" ?>
    <!-- Massage -->
    <texts>
    <text body_name="Rejuvenate your body and soul..." ></text>
    </texts>

    Two questions:
    Can I add a hyperlink to the text in the XML to open a new page? Like you would in HTML: <a href="#" target="_blank">here:</a>

    Can I style the XML with a stylesheet to create Headers, footers, etc?
    I have googled the hell out of this, but my searches are coming up with a lot of almosts, but no hits.

    Thanks for any help!!
    zeech

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Can I add a hyperlink to the text in the XML to open a new page? Like you would in HTML: <a href="#" target="_blank">here:</a>
    Yes, you can. For this to work, you have to pass the string value from the XML in as HTML and the text field in question has to be configured to allow HTML input. You do this through two short lines of AS. If your text field has an instance name of tf, your code might look like this:

    Code:
    tf.html = true;
    tf.htmlText = "This is a <a href='http://google.com'>link</a>.";
    Can I style the XML with a stylesheet to create Headers, footers, etc?
    Why do you want to do that? The XML usually isn't public facing and doesn't need styling. Technically, you can style XML with CSS but I'm not sure if any browsers support it.

  3. #3
    Join Date
    Mar 2008
    Posts
    46
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Still confused.. Help Medyman! thanks

    Thanks Medyman, I am still a bit confused though:

    "Yes, you can. For this to work, you have to pass the string value from the XML in as HTML and the text field in question has to be configured to allow HTML input. You do this through two short lines of AS. If your text field has an instance name of tf, your code might look like this:"

    Code:
    tf.html = true;
    tf.htmlText = "This is a <a href='http://google.com'>link</a>.";

    I am confused, this is AS that goes where? About this code that i have placed:

    stop();
    my_xml = new XML();
    my_xml.load("xml/info_text_galleries.xml");
    my_xml.onLoad = my_function;
    my_xml.ignoreWhite = 1;

    function my_function() {
    raft_mc.raft.text = my_xml.firstChild.childNodes[3].attributes.body_name;
    }

    See site (inprogress here) to see why I want to style the XML
    Click on any menu and take a look at the text, it is ugly!
    http://www.contentx.com/MINAHASA_WEB

    Can I style the XML with a stylesheet to create Headers, footers, etc?
    Why do you want to do that? The XML usually isn't public facing and doesn't need styling. Technically, you can style XML with CSS but I'm not sure if any browsers support it.

  4. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    You would need to change your my_function to this:

    Code:
    function my_function() {
    raft_mc.raft.html = true;
    raft_mc.raft.htmlText = my_xml.firstChild.childNodes[3].attributes.body_name;
    }
    RE: Styling XML
    I misunderstood you. You don't want to style the XML, you want to style the output. The easiest way to do this would be to style the text area and/or component directly using the properties panel. It is also possible to attach a stylesheet to a textarea using the TextField class. I suggest you dig into the livedocs for some examples.

  5. #5
    Join Date
    Mar 2008
    Posts
    46
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Medyman,
    one quick thing,
    How do I add the code into the XML document for it to appear as a URL?
    I tried this:
    <url>http://www.google.com</url>
    and that did not work, it makes my XML undefined
    help!
    thanks mate,
    zeech

Bookmarks

Posting Permissions

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