dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: XML Works when I publish from FLASH Environment NOT from a SWF or in browser

  1. #1
    Senior Member
    Join Date
    Aug 2001
    Location
    New York City
    Posts
    409

    XML Works when I publish from FLASH Environment NOT from a SWF or in browser

    Hi -

    I am loading a feed via XML into a flash file. It works great when I hit "publish" from Flash. BUT when I go and put the file on a server or double click the SWF, or even from an HTML File it goes to the "fail" frame. Below is the code... I hope someone can help :
    Code:
    // Vars
    //
    var itemCount:Number = 5;
    var currCount:Number = 1;
    // var clickTracker:String = "http://ad.doubleclick.net/clk;217764792;6853491;y?";
    var urlQuery:String = "";
    //
    // XML Init
    //
    
    
    var myXML = new XML();
    myXML.ignoreWhite = true;
    myXML.onLoad = function(success) {
    	if (success) {
    		if (myXML.firstChild) {
    			getContent(myXML,"item");
    			debug.text = myXML;
    		} else {
    			gotoAndStop("fail");
    		}
    	} else {
    		gotoAndStop("fail");
    	}
    };
    
    myXML.load("http://www.micelistudios.com/blog/feed");
    //
    // XML Parse
    //
    function getContent(node:XMLNode, name:String) {
    	var content:String = "";
    	var c:XMLNode = node.firstChild;
    	while (c) {
    		if (c.nodeType != 3) {
    			if (c.nodeName == name) {
    				if (currCount<=itemCount) {
    					var itemTitle:String = getNodeText(c.childNodes, "title");
    					
    					var itemLink:String = getNodeText(c.childNodes, "link");
    
    					if (itemTitle.indexOf("    ") != "-1") {
    						itemTitle = itemTitle.split("    ").join(" ");
    						// trace(itemTitle);
    					}
    					var linkPieces:Array = itemLink.split("?");
    					var whichText:MovieClip = eval("rssLink"+currCount);
    				
    					var newString:String = '<a href="'+linkPieces[0]+urlQuery+'" target="_blank">'+itemTitle+'</a>';
    					whichText.htmlText = newString;
    					// trace(newString);
    					currCount++;
    				} else {
    					break;
    				}
    			}
    			content += getContent(c, name);
    		}
    		c = c.nextSibling;
    	}
    	gotoAndStop("success");
    }
    
    function getNodeText(child:Array, searchTerm:String):String {
    	for (var i in child) {
    		if (child[i].nodeName == searchTerm) {
    			return child[i].firstChild.nodeValue;
    		}
    	}
    }

  2. #2
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Have you tested locally? Double check your paths. Send us a link to test with... along with the xml file.

  3. #3
    Senior Member
    Join Date
    Aug 2001
    Location
    New York City
    Posts
    409
    thanks for the reply. Yes... it was the crossdomain.xml file on the server that required my domain to be added. Thanks!

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