A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: flash 8 - using the link from XML

  1. #1
    Member
    Join Date
    Jun 2008
    Posts
    37

    flash 8 - using the link from XML

    hello friends,

    i have been trying to link xml and the button.

    when the button is clicked, it should open the website specified in the xml document.
    i have attached the code, could anyone say how to correct it.


    function loadXML(loaded){
    if(loaded){
    link1 = this.firstChild.childNodes.childNodes[0].firstChild.nodeValue;

    trace("xml loaded");
    }
    else{
    trace("error in loading!!");
    stop();
    }
    }

    stop();
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("links.xml");
    stop();

    -------
    data in xml:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <links>
    <link1>http://www.yahoo.com</link1>
    </links
    -------

    for button:

    on(release){
    getURL(this.firstChild.childNodes.childNodes[0].firstChild.nodeValue);

    }

    -----


    this is not working.
    please help me in sorting out..

    thanks in advance.

    mike.
    -
    aShOkNaNdHa

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    if you only have one link in the xml file -
    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <links>
    <link1>http://www.yahoo.com</link1>
    </links
    PHP Code:
    link1 this.firstChild.firstChild.childNodes.toString();

    // on the button -
    on(release){
    getURL(link1"_blank"); // Fails silently due to FlashPlayer security requirements - so upload and test online

    if you plan to add more links to the xml file -
    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <links>
    <link>http://www.yahoo.com</link>
    <link>http://www.yell.com</link>
    <link>http://www.yellow.com</link>
    </links
    PHP Code:
    xmlData = new XML();
    xmlData.ignoreWhite true;
    xmlData.load("links.xml");

    xmlData.onLoad = function(){
    linksArray this.firstChild.childNodes;
    for (var 
    n=0;n!=linksArray.length;n++){
    trace("linksArray["+n+"] - "+linksArray[n].childNodes);
    }
    };

    ButtonInstanceName1.onRelease = function(){
    trace(linksArray[1].childNodes);
    getURL(linksArray[1].childNodes"_blank");


  3. #3
    Member
    Join Date
    Jun 2008
    Posts
    37

    its working!

    thanks.. :-)
    -
    aShOkNaNdHa

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