Welcome, Guest
  • Author Topic: Add a XML link to a flash button  (Read 6427 times)

    Bruceleeroy

    • Server what's that
    • *
    • Posts: 2
      • View Profile
    Add a XML link to a flash button
    « on: 04/07/09, 13:17 »
    Hey guys,
    I just had a quick question.

    I am using a XML photo gallery from Kirupa that looks like this:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <images>
        <pic>
            <image>http://www.kirupa.com/developer/mx2004/pg/kresge.jpg</image>
            <caption>Kresge</caption>
        </pic>
    </images>

    I have a button on the movie clip that says VISIT WEBSITE and has a rollon and off state.
    I want to be able to change the a href for that button but I cant think of how to do it.

    How can I make it reference the XML file?

    Any help would be greatly appreciated.
    Thanks

    Bruceleeroy

    • Server what's that
    • *
    • Posts: 2
      • View Profile
    Re: Add a XML link to a flash button
    « Reply #1 on: 04/07/09, 14:06 »
    In my Actionscript I added this for the button:

    Code: [Select]
    on (rollOver) {
    gotoAndPlay("over");

    }

    on (rollOut) {
    gotoAndPlay("out");

    }

    on (release) {     
    getURL(_root.linkbtn, "_self");
    }

    Then I updated the XML to be this:
    Code: [Select]
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <images>
        <pic>
            <image>http://www.kirupa.com/developer/mx2004/pg/kresge.jpg</image>
            <caption>Kresge</caption>
    <link>http://www.kirupa.com/developer/mx2004/pg/kresge.jpg</link>
        </pic>
       </images>

    And finally the actionscript that calls the XML looks like this:

    Code: [Select]
    stop();
    function loadXML(loaded) {

    if (loaded) {

    xmlNode = this.firstChild;
    image = [];
    description = [];
    total = xmlNode.childNodes.length;
    for (i=0; i<total; i++) {

    image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
    link[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;

    link.text = _root.linkbtn;

    I am probably missing something really basic.


    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Add a XML link to a flash button
    « Reply #2 on: 04/08/09, 00:16 »
    getURL is the command to read a link.
    Whatever you give to this call, you will load into the current window
    happy flashing
    8)
    Ronald