1 Reply Latest reply on Feb 22, 2010 2:32 PM by o2p

    Dynamic SWFaddress with XML

    o2p

      Hello,
      I have a problem with SWFAddress.
      I come easily to make use of basic functions but I would push a little thing.

      Regarding access to different sections of the site is how I use it and in case of error address, it redirects to the home:

       

       

      #include "com/SWFAddress.as"


                                     

      SWFAddress.onChange = function()
      {
             
      var addr = SWFAddress.getValue();
             
              navigationPage
      (addr);
              trace
      (addr);
             
      var title = 'Titre du site';
             
      var names = SWFAddress.getPathNames();
             
      for (var i = 0; i < names.length; i++) {
                      title
      += ' | ' + names[i].substr(0,1).toUpperCase() + names[i].substr(1);
             
      }
             
      SWFAddress.setTitle(title);
             
      }

      function navigationPage(pageId){
             
             
      if(pageId=="/"){
                     
                     
      SWFAddress.setValue('/accueil/');
             
             
                                     
      }else if(pageId=="/accueil/"){
                              loadMovie
      ("accueil.swf", "holder_mc");

      }else if(pageId=="/audio/"){
                              loadMovie
      ("audio.swf", "holder_mc");

      }else if(pageId=="/contact/"){
                              loadMovie
      ("contact.swf", "holder_mc");

      }else {

                       
      SWFAddress.setValue('/accueil/');

             
              
      }
             
                        
               
                      
      };

      Where things become more difficult is when I want access to music especially in the "audio"
      I add this bit of code to work around the error address:

      }else if(pageId.substr(1,10)=="audio/?ID="){
                      loadMovie
      ("audio.swf", "holder_mc");

      For now, no problem.

      Then I go to my audio.fla and I load my xml:

      loadXML = function (loaded) {
             
             
      if (loaded) {
                      xmlNode
      = this.firstChild;
                      total
      = xmlNode.childNodes.length;
                     
      Thumb = [];
                     
      Title = [];
                     
      Path = [];
                     
      Desc = [];
                      lecteur
      ();
             
      } else {
                      trace
      ("Erreur de chargement");
             
      }

      };

      filename
      = ["portfolio.xml"];
      path
      = "xml/";
      i
      = filename.length;
      k
      = Math.floor(Math.random()*i);

      xmlData
      = new XML();
      xmlData
      .ignoreWhite = true;
      xmlData
      .onLoad = loadXML;
      xmlData
      .load(path+filename[k]);
      stop
      ();


      lecteur
      = function () {
             
      for (i=0; i<total; i++) {
                     
                     
      Title[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
                     
      Desc[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
                     
      Path[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
                     
                      menu_mc
      .bttn_mc.duplicateMovieClip("bttn_mc"+i, i);
                      menu_mc
      ["bttn_mc"+i]._y = (menu_mc.bttn_mc._height+1)*i;
                      menu_mc
      ["bttn_mc"+i].txt_mc.titleDisplay.text = Title[i];
                     
      if (i<9) {
                              num
      = "0"+(i+1);
                     
      } else {
                              num
      = i+1;
                     
      }
                      menu_mc
      ["bttn_mc"+i].num_mc.numDisplay.text = num;
                      menu_mc
      ["bttn_mc"+i].ID = i;
             
      }
              ID
      = 0;
             
             
              menu_mc
      .bttn_mc._visible = false;

      };

      And here is the code that launches the music when I click on a button:

      loadTrack = function () {
             
                     
             
      this._parent._parent._parent.teste.titleDisplay.autoSize = true;
             
      this._parent._parent._parent.teste.titleDisplay.htmlText = Title[ID];
             
      this._parent._parent._parent.teste.titleDesc.autoSize = true;
                     
      this._parent._parent._parent.teste.titleDesc.htmlText = Desc[ID];
              my_sound
      .start();
             
              my_sound
      .loadSound(Path[ID], true);
              holder_mc
      .gotoAndStop(1);
              holder_mc
      .holder.loadMovie(Thumb[ID]);
              titleDisplay
      .text = Title[ID];
              titleDisplay
      .autoSize = true;
             

                             
      };

      Then I added the function loadtrack :

      SWFAddress.setValue('/musique/portfolio/?ID=' + Title[ID]);
                     
                     
      //verifier la valeur du SWFAddress
                      trace
      (SWFAddress.getValue());

      It works it gives me in the address bar addresses like:

       

      http://www.monsite/#/musique/portfolio/?ID=mon_titre_de_musique1

      Now the concern I have is when we go to the address:

       

      http://www.monsite/#/musique/portfolio/?ID=mon_titre_de_musique1

      It goes in the "audio" but obviously it does not read the "Music 1"

      Someone would have any idea of how to make this work.

      I hope I was precise enough in my application
      Thank you in advance for your help

      o2p

        • 1. Re: Dynamic SWFaddress with XML
          o2p Level 1

          So I just consider another method.

          Instead of dealing with an address "Title [ID]" should be whether the place the item in the xml, so I could tell him that if that number is smaller than the total, I run reader with this ID number and if it is larger or has nothing to do I leave the default player.

          The trick is to find how ... A little help would not be refused.

           

          PS: Sorry for my english, I'm French