# \[FLASH8\] News Editor Help

**URL:** <https://forum.kirupa.com/t/flash8-news-editor-help/202854>\
**Category:** flash\
**Created:** [October 5, 2006, 10:49am UTC](https://forum.kirupa.com/t/flash8-news-editor-help/202854 "2006-10-05T10:49:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![True\_Believer](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@True\_Believer](https://forum.kirupa.com/u/True_Believer)\
**Post date:** [October 5, 2006, 10:49am UTC](https://forum.kirupa.com/t/flash8-news-editor-help/202854/1 "2006-10-05T10:49:49Z")

</div>

Hi

I’m trying to create a flash xml editor based on [senocular’s news editor](http://www.kirupa.com/web/xml/examples/newseditor.htm) but I am having some trouble getting the xml file to load. My xml file is structured as below

```auto
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <images>
     <pic>
         <image>images3/car.jpg</image>
         <caption>Car 1</caption>
     </pic>
 </images>

```

I have then altered the actionscript within the news editor and the php file to load in images.xml but it’s not working if anyone can spot my mistake/s I would be most grateful as I’m struggling to find any more. I think the error is in editing actionscript of frame 1.

```auto
var max_images_items = 5;

GetImagePath = function(images_xml, pic_index){
    var pic = images_xml.firstChild.childNodes;
    var image_element = pic[pic_index].firstChild;
    return image_element.firstChild.nodeValue;
}
GetCaptionText = function(images_xml, pic_index){
    var pic = images_xml.firstChild.childNodes;
    var caption_element = pic[pic_index].firstChild.nextSibling;
    return caption_element.firstChild.nodeValue;
}
GetPic = function(images_xml, index){
    var pic = images_xml.firstChild.childNodes;
    return pic[index];
}
GetImagesCount = function(images_xml){
    var pic = images_xml.firstChild.childNodes;
    return pic.length;
}

ShowImages = function(images_xml){
    if (!images_xml.firstChild.hasChildNodes()){
        content_txt.text = "No news available.";
        return (0);
    }
    var pic = images_xml.firstChild.childNodes;
    content_txt.text = "";
    for (var i=0; i<pic.length; i++){
        var image = GetImagePath(images_xml, i);
        var caption = GetCaptionText(images_xml, i);
        content_txt.htmlText += "<b>" + image +"</b><br>"
        content_txt.htmlText += pic*.attributes.date + "<br>" 
        content_txt.htmlText += "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯<br>" 
        content_txt.htmlText += caption +"<br><br>";
    }
}

AddImageEntry = function(images_xml, image, caption){
    var picNode = images_xml.createElement("pic");
    picNode.attributes.date = new Date().toString();
    
    if (caption == "") caption = "(none)";
    var captionNode = images_xml.createElement("caption");
    var captionText = images_xml.createTextNode(caption);
    captionNode.appendChild(captionText);
    picNode.appendChild(captionNode);
    
    if (image == "") image = "(none)";
    var imageNode = images_xml.createElement("image");
    var imageText = images_xml.createTextNode(image);
    imageNode.appendChild(imageText);
    picNode.appendChild(imageNode);

    if (images_xml.firstChild.hasChildNodes()){
        images_xml.firstChild.insertBefore(picNode, images_xml.firstChild.firstChild);
    }else image_xml.firstChild.appendChild(picNode);
    
    while (GetImageCount(images_xml) > max_images_items){
        images_xml.firstChild.lastChild.removeNode();
    }
}

EditImageEntry = function(images_xml, node_index, image, caption){
    var pic = GetPic(images_xml, node_index);
    if (image == "" && caption == ""){
        entry.removeNode();
        return (0);
    }else{
        if (image == "") image = "(none)";
        if (caption == "") caption = "(none)";
    }
    //entry.attributes.date = new Date().toString();
    var imageTextNode = entry.firstChild.firstChild;
    var captionTextNode = entry.firstChild.nextSibling.firstChild;
    imageTextNode.nodeValue = image;
    captionTextNode.nodeValue = caption;
}

SaveImages = function(images_xml){
    content_txt.htmlText = "<i>Saving and Loading...</i>";
    images_xml.xmlDecl = ""; // fixes duplication bug
    images_xml.sendAndLoad(save_script, images_xml);
}
RefreshImages = function(images_xml){
    content_txt.htmlText = "<i>Loading...</i>";
    images_xml.load(xml_file+"?"+new Date().getTime());
}

```

Sorry for the **huge** block of code.
