A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Target Path and Parsing XML

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Location
    Chicago
    Posts
    27

    Target Path and Parsing XML

    Hi All...

    Thanks in advance for taking the time to read this. (I'm using Flash CS3 with AS 2.0)

    I'm having a problem referencing some variables once I create MovieClips out of some of my elements. Here is what I'm doing:

    The user inputs a ZIP code (among other things) which then passes the zip code parameter in the URL to generate some XML. Flash then displays some of the XML in some dynamic text boxes.

    It works just fine on a very basic stage (no symbols, movieclips, etc created), but when I start to create movieclips out of some elements it's stops working... Which tells me that I'm not targeting some of the elements correctly, but I can't seem to get it right

    I attached a zip with two flash files: 1 flash file "XML_loading_passvars.fla" which was working for me. The other file "XML_loading_passvars_combinedtoMC.fla" I started creating movieclips and it no longer worked!


    movie clip A:
    user enters a zip code

    movie clip B:
    user enters another parameter

    In movie clip C, I display some of the returned XML.

    In movie clip B, I have the following actionscript:

    Code:
    stop();
    this.btn_send.onRelease = function() {
    
    	_root.nextFrame();
    	//create the XML object
    	var myXML:XML = new XML();
    
    	//ignore the white space
    	myXML.ignoreWhite = true;
    
    	//define content type
    	myXML.contentType = "text/xml";
    
    	//create the event for when it loads content
    	myXML.onLoad = function(success) {
    
    
    
    		if (success) {
    			//displays the number of results returned
    			results_txt.text = this.firstChild.firstChild.firstChild.nodeValue;
    
    			//displays the number of results returned
    			name_txt.text = this.firstChild.firstChild.nextSibling.firstChild.firstChild.firstChild.nodeValue;
    
    			//traces whether or not the XML loaded successfully
    			trace("yay, this loaded indeed");
    
    			//this will trace the first node
    			trace(this.childNodes);
    
    		} else {
    			trace("there was a major error");
    		}
    	};
    
    
    
    	//now load the content
    	myXML.load("http://xmlurl.com/?"+"search_permitted_zipcode="+this.Symbol3.input_zipcode.zipcode+"&photo="+photo,"_blank","GET");
    
    	// when the load() method is called, the property is set to fales; when the content has loaded, it is changed to true
    	myXML.loaded;
    
    	// this will state whether or not the loaded CML content has child nodes
    	myXML.hasChildNodes();
    
    	//displays a number representing the error that occured, if any
    	myXML.status;
    
    };
    Attached Files Attached Files

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Try this...

    change variable for input_zipcode from 'zipcode' to '_root.zipcode'

    and change in the load statement
    Code:
    myXML.load("http://xmlurl.com/?"+"search_permitted_zipcode="+_root.zipcode+"&photo="+photo,"_blank","GET");

  3. #3
    Junior Member
    Join Date
    Nov 2008
    Location
    Chicago
    Posts
    27
    Weird, but that's not working either. Still tells me that zipcode is undefined.

  4. #4
    Junior Member
    Join Date
    Nov 2008
    Location
    Chicago
    Posts
    27
    I'm sorry, that did work! Thanks again for the heads up. I knew I should have been targeting the variable like that... I guess sometimes it helps to step away for a day and reach out!

    Thanks so much!

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