13 Replies Latest reply on Aug 14, 2009 9:34 PM by kglad

    set dynamic link

    itgate.ir

      hi

      i have a xml file :

       

      <?xml version="1.0" encoding="utf-8"?>
      <gallary>
          <buldingIcon number="4" iconsize="20"/>
          <icon iconUrl="images/1.png" xpos="220" ypos="410"  pageAddress="www.google.com"></icon>
          <icon iconUrl="images/2.png" xpos="190" ypos="150"  pageAddress="www.yahoo.com"></icon>
          <icon iconUrl="images/3.png" xpos="450" ypos="300"  pageAddress="www.alexa.com"></icon>
          <icon iconUrl="images/4.png" xpos="700" ypos="490"  pageAddress="www.alexa.com"></icon>
      </gallary>

       

      and the action script code , than read the xml file then crate the empty movieclip for each icons , set the position this movieclip to x=xpos and y=ypos , and finally load the iconUrl to movieclip :

       

      var myXml:XML = new XML();
      myXml.ignoreWhite = true;
      myXml.load("config.xml");
      myXml.onLoad = function(success) {
          num=myXml.firstChild.childNodes[0].attributes.number;
          for (i=1; i<=num; i++) {

              loader = this.firstChild.childNodes[i].attributes.iconUrl;
              var targetMC:MovieClip = _root.createEmptyMovieClip("al"+i, 10+i);
              targetMC.loadMovie(loader);
              targetMC._x = this.firstChild.childNodes[i].attributes.xpos;
              targetMC._y = this.firstChild.childNodes[i].attributes.ypos;
              t=this.firstChild.childNodes[i].attributes.pageAddress;
              targetMC.onMouseDown=function(){
              getURL(t,"_blank");

              }
          }
      }

       

      now i set the html link to each icons , that load in the movieclip.

      in the red line code , i want solve this problem but wrong .

      can you help me what can i do set the html address in pageAddress attribute in xml file to per icons ?


      besr regards


        • 1. Re: set dynamic link
          kglad Adobe Community Professional & MVP

          try:

           


           

          <?xml version="1.0" encoding="utf-8"?>
          <gallary>
              <buldingIcon number="4" iconsize="20"/>
              <icon iconUrl="images/1.png" xpos="220" ypos="410"  pageAddress="www.google.com"></icon>
              <icon iconUrl="images/2.png" xpos="190" ypos="150"  pageAddress="www.yahoo.com"></icon>
              <icon iconUrl="images/3.png" xpos="450" ypos="300"  pageAddress="www.alexa.com"></icon>
              <icon iconUrl="images/4.png" xpos="700" ypos="490"  pageAddress="www.alexa.com"></icon>
          </gallary>

           

          and the action script code , than read the xml file then crate the empty movieclip for each icons , set the position this movieclip to x=xpos and y=ypos , and finally load the iconUrl to movieclip :

           

          var myXml:XML = new XML();
          myXml.ignoreWhite = true;
          myXml.load("config.xml");
          myXml.onLoad = function(success) {
              num=myXml.firstChild.childNodes[0].attributes.number;
              for (i=1; i<=num; i++) {

                  loader = this.firstChild.childNodes[i].attributes.iconUrl;
                  var targetMC:MovieClip = _root.createEmptyMovieClip("al"+i, 10+i);
                  targetMC.loadMovie(loader);
                  targetMC._x = this.firstChild.childNodes[i].attributes.xpos;
                  targetMC._y = this.firstChild.childNodes[i].attributes.ypos;
                  targetMC.t=this.firstChild.childNodes[i].attributes.pageAddress;


                  targetMC.onMouseDown=function(){
                  getURL(this.t,"_blank");

                  }
              }
          }

           



          1 person found this helpful
          • 2. Re: set dynamic link
            itgate.ir Level 1

            thanks

            but not work

            • 3. Re: set dynamic link
              kglad Adobe Community Professional & MVP

              that code works but you probably don't want to use onMouseDown.  use:

               


               


               

              <?xml version="1.0" encoding="utf-8"?>
              <gallary>
                  <buldingIcon number="4" iconsize="20"/>
                  <icon iconUrl="images/1.png" xpos="220" ypos="410"  pageAddress="www.google.com"></icon>
                  <icon iconUrl="images/2.png" xpos="190" ypos="150"  pageAddress="www.yahoo.com"></icon>
                  <icon iconUrl="images/3.png" xpos="450" ypos="300"  pageAddress="www.alexa.com"></icon>
                  <icon iconUrl="images/4.png" xpos="700" ypos="490"  pageAddress="www.alexa.com"></icon>
              </gallary>

               

              and the action script code , than read the xml file then crate the empty movieclip for each icons , set the position this movieclip to x=xpos and y=ypos , and finally load the iconUrl to movieclip :

               

              var myXml:XML = new XML();
              myXml.ignoreWhite = true;
              myXml.load("config.xml");
              myXml.onLoad = function(success) {
                  num=myXml.firstChild.childNodes[0].attributes.number;
                  for (i=1; i<=num; i++) {

                      loader = this.firstChild.childNodes[i].attributes.iconUrl;
                      var targetMC:MovieClip = _root.createEmptyMovieClip("al"+i, 10+i);
                      targetMC.loadMovie(loader);
                      targetMC._x = this.firstChild.childNodes[i].attributes.xpos;
                      targetMC._y = this.firstChild.childNodes[i].attributes.ypos;
                      targetMC.t=this.firstChild.childNodes[i].attributes.pageAddress;


                     targetMC.onRelease=function(){
                      getURL(this.t,"_blank");

                      }
                  }
              }

               



              1 person found this helpful
              • 4. Re: set dynamic link
                itgate.ir Level 1

                i replace this code

                 

                targetMC.t=this.firstChild.childNodes[i].attributes.pageAddress;

                targetMC.onRelease=function(){
                        getURL(this.t,"_blank");
                }

                 

                but not work yet

                • 5. Re: set dynamic link
                  kglad Adobe Community Professional & MVP

                  are you testing in your browser?

                  • 6. Re: set dynamic link
                    itgate.ir Level 1

                    yes , i test in firefox and IE but not work .

                    • 7. Re: set dynamic link
                      kglad Adobe Community Professional & MVP

                      fix your getURL() so it prepends http:// and what does adding the trace() functions below show after a few clicks:

                       


                       

                       

                      var myXml:XML = new XML();
                      myXml.ignoreWhite = true;
                      myXml.load("config.xml");
                      myXml.onLoad = function(success) {
                          num=myXml.firstChild.childNodes[0].attributes.number;
                          for (i=1; i<=num; i++) {

                              loader = this.firstChild.childNodes[i].attributes.iconUrl;
                              var targetMC:MovieClip = _root.createEmptyMovieClip("al"+i, 10+i);
                              targetMC.loadMovie(loader);
                              targetMC._x = this.firstChild.childNodes[i].attributes.xpos;
                              targetMC._y = this.firstChild.childNodes[i].attributes.ypos;
                              targetMC.t=this.firstChild.childNodes[i].attributes.pageAddress;

                      trace(targetMC.t);

                       

                              targetMC.onRelease=function(){

                      trace(this.t);
                             getURL("http://"+this.t,"_blank");
                              }
                          }
                      }

                       



                      • 8. Re: set dynamic link
                        itgate.ir Level 1

                        not work

                        the second trace not running

                        output:

                        www.google.com

                        • 9. Re: set dynamic link
                          kglad Adobe Community Professional & MVP

                          var myXml:XML = new XML();
                          myXml.ignoreWhite = true;
                          myXml.load("config.xml");
                          myXml.onLoad = function(success) {
                              num = myXml.firstChild.childNodes.length;
                              for (i=1; i<num; i++) {

                           

                                  loader = this.firstChild.childNodes[i].attributes.iconUrl;
                                  trace(i+": "+loader)
                                  var parentMC:MovieClip = _root.createEmptyMovieClip("al"+i, 10+i);
                                  var targetMC:MovieClip = parentMC.createEmptyMovieClip("targetMC", 1);
                                  targetMC.loadMovie(loader);
                                  targetMC._x = this.firstChild.childNodes[i].attributes.xpos;
                                  targetMC._y = this.firstChild.childNodes[i].attributes.ypos;
                                  parentMC.t = this.firstChild.childNodes[i].attributes.pageAddress;

                           


                                  parentMC.onRelease = function() {
                                      getURL("http://"+this.t, "_blank");
                                  };
                              }
                          };

                          • 10. Re: set dynamic link
                            itgate.ir Level 1

                            thanks a lot

                            the problem is corrected

                             

                            can you tell me , how occured this problem ? and why the parentMC crate a  targetMC ?

                             

                             

                            • 11. Re: set dynamic link
                              kglad Adobe Community Professional & MVP

                              any movieclip that's a load target loses its mouse handlers.  you either have to create a child movieclip that's the load target (which is what i did) or wait until loading is complete to define mouse handlers.

                              • 12. Re: set dynamic link
                                itgate.ir Level 1

                                thanks for  yor helps

                                 

                                best regards .

                                • 13. Re: set dynamic link
                                  kglad Adobe Community Professional & MVP

                                  you're welcome.