0

I'm developing a tool for Adobe Animate and I ran into some issues with loaders.

I load a XML file in this tool and when I press a button, I want it to create a node in my XML file. But nothing happens...

I think it's caused by the XML being used with the loader and so I can't write in it.

I would like the XML file to be editable again after his loading, do you know a way to do this?

Thanks ! Here is the code :

var buttonListXML:XML = new XML();
var MenuXMLLoader:URLLoader = new URLLoader();

function loadXML(){
        MenuXMLLoader.load(new URLRequest(pathXML_RELATIVE));
        MenuXMLLoader.addEventListener(Event.COMPLETE, addNodeToXML);
}

function addNodeToXML(e:Event){
        buttonListXML = new XML(e.target.data);
        //for example, i modify this value
        buttonListXML.button[2].@number = 555;
        //here i try to delete the list
        MenuXMLLoader.removeEventListener(Event.COMPLETE, addNodeToXML);
        MenuXMLLoader = null;
        //everything is OK in the output
        trace(buttonListXML)
        //pathXML_ABSOLUTE cibling my XML file but nothing happens...
     MMExecute("FLfile.write("+pathXML_ABSOLUTE+","+buttonListXML+");");
}
General Grievance
  • 4,555
  • 31
  • 31
  • 45
Mat Gap
  • 1
  • 1
  • 1
    There's a magic command called **trace(...)** which allows you to debug output literally anything along the way. So, the first thing you do in such a case is setting a lot of **trace**s along your algorithm and check if the things are what you expect them to be at every point. This way you narrow down your big code to a single line that gives you the problem. – Organis Sep 21 '21 at 19:38
  • Thanks for your answer. I've tried with a lot of **trace()** command every where. All seems ok. But nothing is writing into my XML File. If i write into a new file, it works, but not into the same file... – Mat Gap Sep 22 '21 at 09:18
  • Well, that may be the case, the file is still open and cannot be written in the meanwhile. Then you should wait a bit after you dispose of the **URLLoader** instance (also try calling **System.gc();** maybe), and only then attempt to overwrite it. Also, **MMExecute(...)** seems to return a result **String**, might be worth to **trace** it as well. – Organis Sep 22 '21 at 13:32

0 Answers0