15 Replies Latest reply on Oct 3, 2006 5:26 AM by Glazer

    Flash and XML, 2 problems

      I am reading a XML file from flash and got 2 little questions I just cant seem to get working.

      my XML is build like this:


      and the flash code where I load my XML:

      AlgemeenXML = new XML();
      AlgemeenXML.ignoreWhite = true;
      AlgemeenXML.onLoad = function(ok)
      if(ok == true)

      function Publish(AlgemeenXMLNode)
      var itemNode = AlgemeenXMLNode.firstChild;
      var leadNode = itemNode.firstChild;
      var leadNode_value = leadNode.firstChild;
      var fileNode = leadNode.nextSibling;
      var fileNode_value = fileNode.firstChild;
      var sampleLink = '<a href="'+fileNode_value+'">'+leadNode_value+'</a>';
      myText.text = sampleLink

      my 2 questions:
      1. Why wont it loop trough the XML? it only takes the first XML record (and how would I get it to get the other records as well)

      en 2:I want to change the HTML hyperlink into a link that uses a FScommand, so it can load a bat from within flash, no clue where to start (can make functions)

      thanks ahead,
        • 1. Re: Flash and XML, 2 problems
          Glazer Level 1
          Hi Aart,

          The code you have so far looks good, it just needs a bit of tweaking.

          Well there are several things:
          1. If you want to loop through the xml nodes, you'll have to use a for loop, or whatever other loop you're comfortable with,

          2. If you want to use html type formatting in a flash textfield you'll need to state that you want the textfield to behave that way "myText.html = true". Plus you'll need to use the ".htmlText = " statement, (not ".text = ") when setting values for the textfield.

          3. Regarding the FSCommand, it depends which version of the flash player you're publishing to, since some of the latest versions do not support that FSCommand's.

          • 2. Flash and XML, 2 problems
            Aartje21 Level 1
            changed it, now it only takes the last record (well it shows it goes trough the XML file now, its a step forward :P

            defined the html text already. and its working with HTML links. FScommand does work in this version of flash (8), but I can't seem to get it in a link. tried it with making a function, but no clue how to make a clickable textlink in flash

            FScommand ("exec", "filename.bat") works perfectly, but I want a onclick on variable text :(

            thanks for the answer, got something new to look at ;)

            *edit* btw, it will be in a projector, it needs to open PDF files (I do that trough a bat), its for a documentation CD */edit*
            • 3. Re: Flash and XML, 2 problems
              Glazer Level 1
              To get all the links to appear in your textfield, use the following:
              myText.htmlText += sampleLink;

              instead of:
              myText.htmlText = sampleLink;

              and to make it a bit prettier (easier to read):
              myText.htmlText += sampleLink + ", ";

              These are only suggestions, not sure how you're flash file is structured or how you would like to display the links / text / information. If you could perhaps take a screenshot of what you have so far, that may help :)
              • 4. Re: Flash and XML, 2 problems
                Aartje21 Level 1
                got a sample image here: http://storage.oxle.com/files/31/example.jpg

                the weird thing is, when I click the link it shows next to the old text now, and a clear refuses to stop clearing after I clicked it :(
                • 5. Flash and XML, 2 problems
                  Aartje21 Level 1
                  ( I got a <BR> in now for the enters ;) )

                  *edit* got the frame clearing working */edit*

                  now just that FS command, how can I ever use a function behind a clickable text like that (as a hyperlink, but with a function instead)
                  • 6. Re: Flash and XML, 2 problems
                    Glazer Level 1
                    clickable text that links up to a function (from my experience is not possible).

                    I've created a little sample file you can look at:

                    It's basically got a "pdfLink" mc which is attached dynamically depending on how many items you have in your xml file.
                    You would then replace the placeholder fscommand function that's in there now, with your fscommand function.

                    Take a look at it and let me know what you think.

                    • 7. Re: Flash and XML, 2 problems
                      Aartje21 Level 1
                      almost works perfectly, except that it doesnt run the flash. (now please forgive me for being a newbie)

                      changed code to [code] this[curr_pdfLink]._y = this[prev_pdfLink]._y + this[prev_pdfLink]._height;
                      this[curr_pdfLink].pdfLabel.text = sampleLink;
                      this[curr_pdfLink].HitArea.onRelease = function()
                      FSCommand("exec", fileNode_value);

                      but seems like it isnt running the FScommand. is that because it has to be named in the function first?

                      your help is greatly apreciated (if I spell that right), someday I will understand this XML <> flash thingie
                      • 8. Re: Flash and XML, 2 problems
                        Glazer Level 1
                        first check that your fscommand works...
                        Try hardcoding the ".bat" file into the function, eg:

                        this[curr_pdfLink].HitArea.onRelease = function()
                        FScommand ("exec", "filename.bat");

                        doesn't matter which "filename.bat" it is.

                        Try that first and see if it works.
                        • 9. Re: Flash and XML, 2 problems
                          Glazer Level 1
                          Q: What version of Flash are you using to author / create your flash file?
                          If it's Flash 8 then you'll need to create a folder named "fscommand" where you will place your pdf's.

                          Q: What version of the Flash Player are you targeting (in the Publich settings)?
                          Make sure your publishing as an .exe not a .swf

                          Quote from Flash 8 Documentation:
                          "The exec command can contain only the characters A-Z, a-z, 0-9, period (.), and underscore (_). The exec command runs in the subdirectory fscommand only. In other words, if you use the exec command to call an application, the application must reside in a subdirectory named fscommand. The exec command works only from within a Flash projector file."
                          • 10. Re: Flash and XML, 2 problems
                            Aartje21 Level 1
                            got it ALMOST working, it opens a .bat now (FScommand should be fscommand, I am learning a little bit here). but the problem, it opens the .bat of the last record only., so for every I click it opens the last bat.

                            (getting excited here, its almost working, and been working too much on this the last few days)
                            • 11. Re: Flash and XML, 2 problems
                              Glazer Level 1
                              ok, cool...
                              now you just need to use the previous code:
                              this[curr_pdfLink].HitArea.onRelease = function()
                              FSCommand("exec", fileNode_value);

                              instead of:
                              this[curr_pdfLink].HitArea.onRelease = function()
                              FScommand ("exec", "filename.bat");

                              then it should work... (holding thumbs)
                              • 12. Re: Flash and XML, 2 problems
                                Aartje21 Level 1
                                no, thats what I meant last time (already tried that), fileNode_value contains the last record only? maybe it works the same with the thingie
                                • 13. Re: Flash and XML, 2 problems
                                  Glazer Level 1
                                  sorry, there's a mistake in the code:

                                  try using this:

                                  this[curr_pdfLink].fileNode_value = fileNode_value;
                                  this[curr_pdfLink].HitArea.onRelease = function()
                                  fscommand("exec", this._parent.fileNode_value);
                                  • 14. Re: Flash and XML, 2 problems
                                    Aartje21 Level 1
                                    got it working, many many many thanks! now I just have to fit the menu and stuff, but I understand that

                                    • 15. Re: Flash and XML, 2 problems
                                      Glazer Level 1
                                      cool, good luck and keep flashing!