4 Replies Latest reply on May 24, 2006 1:26 PM by aniebel

    Determining empty childnodes

    aniebel Level 2
      Hi, I have a PHP script that generates XML based on an HTML form page with 16 fields in it (8 song name and 8 file name). I left all fields there as the client may want to add more down the road. The problem is that the empty fields are causing buttons to be created also. Do I edit the AS to say something like "if the childnode attribute is not null, make these buttons" ? or is this the wrong approach?

      Here is how I'm creating the buttons:
        • 1. Re: Determining empty childnodes
          Level 7
          if i get you right you might use sth like:

          if(playlist.firstChild.childNodes .attributes.file != null &&
          playlist.firstChild.childNodes
          .attributes.file !=""){
          // create button or whatever
          }


          perry


          "aniebel" <webforumsuser@macromedia.com> schrieb im Newsbeitrag
          news:e51foe$bcl$1@forums.macromedia.com...
          > Hi, I have a PHP script that generates XML based on an HTML form page with
          16
          > fields in it (8 song name and 8 file name). I left all fields there as the
          > client may want to add more down the road. The problem is that the empty
          fields
          > are causing buttons to be created also. Do I edit the AS to say something
          like
          > "if the childnode attribute is not null, make these buttons" ? or is this
          the
          > wrong approach?
          >
          > Here is how I'm creating the buttons:
          >
          > playlist.onLoad = function(success) {
          > if (success) {
          > trace("xml loaded");
          > _global.songname = [];
          > _global.songfile = [];
          > for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
          > _global.songname =
          playlist.firstChild.childNodes
          .attributes.sName;
          > _global.songfile = playlist.firstChild.childNodes.attributes.file;
          > attachMovie("butTemp", "but"+i, i+50);
          > eval("but"+i).id = i;
          > _level0.audioHolder_mc["but"+i]._x = 3;
          > _level0.audioHolder_mc["but"+i]._y = 40+(i*22);
          > _level0.audioHolder_mc["but"+i].but_txt.text = songname ;
          > _level0.audioHolder_mc["but"+i].butshadow_txt.text = songname
          ;
          > if (i>=4) {
          > _level0.audioHolder_mc["but"+i]._x = 132;
          > _level0.audioHolder_mc["but"+i]._y = -48+(i*22);
          > }
          > _level0.audioHolder_mc["but"+i].onRelease = function() {
          > clearInterval(timeInterval);
          > _level0.audioHolder_mc.timeDisplay_txt.text = "00:00";
          > _level0.audioHolder_mc.sound_mc.songStarter(songfile[this.id]);
          > };
          > }
          > }
          > _level0.audioHolder_mc.createEmptyMovieClip("sound_mc",
          > this.getNextHighestDepth());
          > _global.song_nr = [0];
          > _level0.audioHolder_mc.sound_mc.songStarter(songfile[0]);
          > };
          >


          • 2. Re: Determining empty childnodes
            aniebel Level 2
            ok, cool, thanks... so what's the difference between
            "! = null" and "! = '' "?

            Also, should it be
            ! == "" instead?
            • 3. Re: Determining empty childnodes
              Rothrock Level 5
              I have a different approach. And maybe it isn't any good for what you are doing or maybe it will give you ideas.

              Personally I wouldn't send empty child nodes. I don't have an PHP experience so maybe that is something that has to happen this way. But why send them if they are empty? I've been around long enough (and am bitter and cynical enough) that something like this seems a likely senario.

              The server upgrades its version of PHP from version xx.xxx.xx.x to xx.xxx.xx.x+1 (a very minor revision!) and suddenly your "empty" nodes have a different kind of empty/null character – one that Flash will start interpretting as data.

              Or something like that, y'know what I mean? So anyways I would design my Flash to accept a variable number of nodes, with a limit of 16 or what have you. Then, if possible, have the PHP only send the information that actually exists.

              Make sense? or am I just crazy?
              • 4. Re: Determining empty childnodes
                aniebel Level 2
                That's a good idea and that had occurred to me but I know less about PHP than I do AS2 so I thought I'd try it from the Flash end first. I bet if I do enough digging, I can find the answer on the PHP end (or at least get my nails dirty trying).