dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: loading variables into flash from xml

  1. #1
    Senior Member
    Join Date
    Mar 2005
    Location
    MI
    Posts
    279

    loading variables into flash from xml

    I am a little rusty with my action script and i am still using 2.0 in my project. I need to load variables in to flash from an xml file and i just can't seem to get it to work.

    here is my flash code:
    on (release) {
    getxmldata = new XML();
    getxmldata.load("xmldata.xml","");
    if (getxmldata.loaded) {
    var p = getxmldata.firstChild;
    xmldoc = getxmldata.childNodes;
    node_name = p.nodeName;
    box_1 = p.attributes.box_1;
    box_2 = p.attributes.box_2;
    } else {
    box_1 = "not loaded";
    box_2 = "not loaded";
    }
    }
    And here is my xml code:
    <?xml version="1.0" encoding="utf-8"?>
    <BOX_INFO BOX_1="Box one info" BOX_1="Box two info" />
    But this is not working and i would like some help.

    Thanks a buch
    Our greatest fear is not that we are inadequate,
    but that we are powerful beyond measure.

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    I've included an example of reading an xml file. There are more things, but this should help you understand the full principle.

    LINK: http://www.mediafire.com/?3monnkmcexm
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    <?xml version="1.0" encoding="utf-8" ?><BOX_INFO BOX_1="Box one info" BOX_2="Box two info" />
    Code:
    on (release) {
    	getxmldata = new XML();
    	getxmldata.onLoad = function(success) {
    		if (success) {
    			trace(getxmldata.firstChild)
    			var p = getxmldata.firstChild;
    			box_1 = p.attributes.BOX_1;
    			box_2 = p.attributes.BOX_2;
    			trace(box_1);
    			trace(box_2);
    		} else {
    			box_1 = "not loaded";
    			box_2 = "not loaded";
    		}
    	};
    	getxmldata.load("xmldata.xml");
    }

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