A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How To Use Xml Data To Geturl

  1. #1
    Senior Member zervell's Avatar
    Join Date
    May 2004
    Posts
    259

    How To Use Xml Data To Geturl

    I know alot of people have had the problem of linking there xml file from an outside source. My problem is that I want to us xml to dynamically set up links to foreign addresses(as in not local;i.e bob.com/bob.jgp and bob.com/bob2.jgp)like www.yahoo.com ect.

    my flash code is simple, it loads the xml file, reads the location of the url with in the xml file. there is no real error persay in the code but more of a problem with the flash security.

    PHP Code:
    var my_xml = new XML();
    my_xml.load("cvb.xml");
    my_xml.ignoreWhite true;
    var 
    loaded_status:Boolean false;
    var 
    percent:Number 0;
    var 
    url:String;
    function 
    onEnterFrame() {
        
    loadbar._xscale percent;
        
    load_xml();
        if (
    percent == 100) {
            
    button_xml_hyperlink(_button1);
            
    //trace(my_xml.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue);//town name
            //trace(my_xml.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue);//description
            //trace(my_xml.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue);//url
        
    }
    }
    function 
    load_xml() {
        if (
    loaded_status == false) {
            
    myxml_total my_xml.getBytesTotal();
            
    myxml_loaded my_xml.getBytesLoaded();
            
    percent = (myxml_loaded/myxml_total)*100;
            if (
    percent == 100) {
                
    url my_xml.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
                
    loaded_status true;
                
    delete this;
            }
        }
    }
    function 
    button_xml_hyperlink(_button_name) {
        
    _button_name.onRelease = function() {
            
    loadMovie(urlhero2);
            
    getURL(url"_blank");
        };

    this is my xml

    PHP Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <state>
        <town>
            <townname>Huntington</townname>
            <description>Huntington, is cool!</description>    
            <url><![CDATA[http://www.yahoo.com/index.html]]></url>
        </town>
        <town>
            <townname>Bob Land</townname>
            <description>Bob Land, has the largest people in the world.</description>    
            <url>http://www.google.com</url>
        </town>    
    </state>
    in a nutshell i want to know what i need to do to get this working. thank you in advanced
    CEO OF

  2. #2

  3. #3
    Senior Member zervell's Avatar
    Join Date
    May 2004
    Posts
    259

    wow

    you made it read the link from the xml file? if you used my code what did you do differently. It looks as if you took the data from the xml file and displayed it in a textfield and did a code something like getURL(textfield.text) is that what you did?
    CEO OF

  4. #4
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    that is your code. All I did was put a textfield onstage with a variable name of (url) so you could see what node it was pulling. Otherwise it's your pasted.

  5. #5
    Senior Member zervell's Avatar
    Join Date
    May 2004
    Posts
    259

    you did change something

    you did change something. by the way i need a friend like you the way you write code is unmatched, not to toot your horn. I looked at the code you've redone and I found that when I put the full URL address like you did, I don't get the security problems. when I would write the xml file as an in house file any address outside my site was a problem. so you did change something. thanks alot I wish you put the code out in the first place, thank you. while I have your ear (so to speak), i what 'return' dose?
    CEO OF

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