A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: [RESOLVED] XML Image tag contents not loading into SWF

  1. #1
    Join Date
    Dec 2007

    resolved [RESOLVED] XML Image tag contents not loading into SWF


    I've just finished a tutorial on how to create an XML with flash, and I created a dynamic news board. However, I want a little icon to appear next to the title of each new entry that I add that <img-url> tag to. I do not have the foggiest clue how to add an image using XML even though I've searched this forum and googled it... It seems like I am missing something. Am I supposed to have a movie clip with an instance name (in the FLA) where the image should eventually go? I'm confused. Any help would be greatly appreciated.

    The code for the XML is this:

    <?xml version="1.0" encoding="UTF-8"?>
    <title>Welcome To Our New Shield Of Wisdom Website</title><image>new.jpg</image>  <date>July 8, 2009</date>
    <content>We are pleased to announce that we are now accessible online. Get the latest lessons, studies, teachings here at our site, as well as archived videos, PDF text downloads, audio of past lessons and classes... 
    The ActionsScript is:

    var newsX:XML;
    var newsList:XMLList;
    var output:String = "";
    var style:StyleSheet = new StyleSheet();
    news_box.styleSheet = style;
    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE, onComplete);
    loader.load(new URLRequest("../../swf/news/newstxt.xml"));
    var imageLoader:Loader = new Loader();
    imageLoader.addEventListener(Event.COMPLETE, onComplete);
    imageLoader.load(new URLRequest("new.jpg"));
    function onComplete(e:Event):void
    	newsX = new XML(loader.data);
    	newsList = newsX.story;
    	for(var i:uint = 0; i < newsList.length(); i++)
    	output += "<br /><div1>" + newsList[i].title + [Add Image Here] + "</div1>" + "<div2>" + newsList[i].date + "</div2>";
    	output += "<p>" + newsList[i].content + "</p>";
    	output += "<br />";
    	news_box.htmlText = output;

    What is happening here is that I found a snippet of code "imageLoader" and that brought the image in, but image tag did not. the reason why I'd rather use the image tag is so that I can decide when I want to add it to a news entry, and leave it off when I don't want to add it. I also know that stopping at addChild does not help, but I don't know what and addChild is - and not really sure where to go from there. Just trying to make it work and will understand it as I see the logic. Attached is a screen shot. The image is in the top left corner, but I need it to go directly after the news title and only when called by a tag in the XML.

    Thank you all in advance.

    Last edited by anna_2010; 07-12-2009 at 10:37 AM.

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