A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Passing XML into flash query

Hybrid View

  1. #1
    Senior Member
    Join Date
    Aug 2000
    Location
    Seoul, South Korea
    Posts
    1,310

    Passing XML into flash query

    Hi,
    I'm currently passing the following XML into flash:
    Code:
    <users>
      <user>
        <user_id>1</user_id> 
        <full_name>Shaun McAleer</full_name> 
        <email>michael@pmpak.com</email> 
      </user>
      <user>
        <user_id>9</user_id> 
        <full_name>Gerard Kelly</full_name> 
        <email>camcim@gmail.com</email> 
      </user>
    </users>
    My actionscript looks like this:
    Code:
    function loadXML(loaded) {
    if (loaded) {
    	
    _root.company_name.text = this.firstChild;
    
    for (var j = 0; j<this.firstChild.childNodes.length; j++) {
    
    	_root.user_id = this.firstChild.childNodes[j].childNodes[0];
    	_root.full_name = this.firstChild.childNodes[j].childNodes[1];
    	_root.email = this.firstChild.childNodes[j].childNodes[2];
    	
    	attachMovie("dynamic_id", "newClip_mc"+j, j, 
    	{		
    		user_id:_root.user_id,
    		name_str:_root.full_name, 
    		email_str:_root.email, 
    		_x:0, _y:j*90	
    	}
    	);	
    }
    
    } else { 
      trace("file not loaded!"); 
    } 
    }
    
    xmlData = new XML(); 
    xmlData.ignoreWhite = true; 
    xmlData.onLoad = loadXML; 
    xmlData.load("index.php");
    How would i go about adding a generic value, lets say company_name for all output in the XML so i can call it in the actionscript here:
    Code:
    _root.company_name.text = company_name;
    Cheers
    !.....................................COMING SOON

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    PHP Code:
    <users company="Joe Bloggs">
      <
    user>
    ........
    snip............
    </
    users
    Code:
    function loadXML(loaded) {
    if (loaded) {
    rootN = this.firstChild
    _root.company_name.text = rootN.attributes.company;
    ........snip............
    };
    is this what you seek ?

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