18 Replies Latest reply on Aug 12, 2009 7:37 AM by kglad

    load image

    itgate.ir Level 1

      hi

      please see this xml code

       

      <?xml version="1.0" encoding="utf-8"?>
      <gallary>
          <icon iconUrl="images/1.png" xpos="150" ypos="100"></icon>
          <icon iconUrl="images/2.png" xpos="190" ypos="150"></icon>
      </gallary>

       

       

       

       

      then ;

      i want to load per iconUrl in the xpos and ypos , by the following code

       

      var myXml:XML = new XML();
      myXml.ignoreWhite = true;
      myXml.load("config.xml");
      myXml.onLoad = function(success) {
          for(i=0 ; i<=myXml.childNodes.length ;i++){
                  loader = this.firstChild.childNodes[i].attributes.iconUrl;
                  _root.createEmptyMovieClip("al",10);
                 
      al.loadMovie(loader);
                 
      al._x=this.firstChild.childNodes[i].attributes.xpos;
                 
      al._y=this.firstChild.childNodes[i].attributes.ypos;
          }
      }

       

       

       

      this code load correct the latest iconUrl in xml file to specific position but the problem is , the other images is not load or maybe unload because the name of the movie clip that would be load the image is not different .

      my question is :

      what can i do rename the movie clip dynamically ?

       

       

      best regards .

        • 1. Re: load image
          kglad Adobe Community Professional & MVP

          you're replacing your target movieclips by using the same depth.  try:

           

          itgate.ir wrote:

           

          hi

          please see this xml code

           

          <?xml version="1.0" encoding="utf-8"?>
          <gallary>
              <icon iconUrl="images/1.png" xpos="150" ypos="100"></icon>
              <icon iconUrl="images/2.png" xpos="190" ypos="150"></icon>
          </gallary>

           

           

           

           

          then ;

          i want to load per iconUrl in the xpos and ypos , by the following code

           

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

                     var targetMC:MovieClip = _root.createEmptyMovieClip("al"+i,10+i);

                      _root.targetMC.loadMovie(loader);

                      _root.targetMC._x=this.firstChild.childNodes[i].attributes.xpos;

                      _root.targetMC._y=this.firstChild.childNodes[i].attributes.ypos;

              }
          }

           

           

           

          this code load correct the latest iconUrl in xml file to specific position but the problem is , the other images is not load or maybe unload because the name of the movie clip that would be load the image is not different .

          my question is :

          what can i do rename the movie clip dynamically ?

           

           

          best regards .

          1 person found this helpful
          • 2. Re: load image
            itgate.ir Level 1

            thanks

            but not work yet

             

            becuase the first parameters of createEmptyMovieClip is string and not suport the variables .

            • 3. Re: load image
              kglad Adobe Community Professional & MVP

              your last post doesn't make sense.

               

              copy and paste your corrected code.

              • 4. Re: load image
                itgate.ir Level 1

                excuse me

                can you see this file please

                http://rapidshare.com/files/265665494/load_icon.rar.html

                i replace your code , but not work

                • 5. Re: load image
                  kglad Adobe Community Professional & MVP

                  i generally don't download and correct files unless i'm hired to do that.  i don't believe that should be needed in your situation.  post your code.

                  • 6. Re: load image
                    itgate.ir Level 1

                    excuse me for sending the file , i don't know .

                     

                    the code :

                    var myXml:XML = new XML();
                    myXml.ignoreWhite = true;
                    myXml.load("config.xml");
                    myXml.onLoad = function(success) {
                        for(i=0 ; i<=myXml.childNodes.length ;i++){
                                loader = this.firstChild.childNodes[i].attributes.iconUrl;
                                var targetMC:MovieClip = _root.createEmptyMovieClip("al"+i,10+i);
                                _root.targetMC.loadMovie(loader);
                                _root.targetMC._x=this.firstChild.childNodes[i].attributes.xpos;
                                _root.targetMC._y=this.firstChild.childNodes[i].attributes.ypos;

                        }
                    }

                    • 7. Re: load image
                      kglad Adobe Community Professional & MVP

                      copy and paste the trace output from:

                       

                      var myXml:XML = new XML();
                      myXml.ignoreWhite = true;

                       

                      myXml.onLoad = function(success) {
                          for (i=0; i<=myXml.childNodes.length; i++) {
                              loader = this.firstChild.childNodes[i].attributes.iconUrl;
                              var targetMC:MovieClip = _root.createEmptyMovieClip("al"+i, 10+i);
                              _root.targetMC.loadMovie(loader);
                              trace(_root.targetMC+": "+loader);
                              _root.targetMC._x = this.firstChild.childNodes[i].attributes.xpos;
                              _root.targetMC._y = this.firstChild.childNodes[i].attributes.ypos;

                       

                          }
                      };

                       

                      myXml.load("config.xml");

                      • 8. Re: load image
                        itgate.ir Level 1

                        output :

                         

                        undefined: images/1.png
                        undefined: images/2.png

                        • 9. Re: load image
                          kglad Adobe Community Professional & MVP

                          what flash player version are you publishing for?

                          • 10. Re: load image
                            itgate.ir Level 1

                            flash player 10

                            • 11. Re: load image
                              kglad Adobe Community Professional & MVP

                              that should be:

                               


                               

                              var myXml:XML = new XML();
                              myXml.ignoreWhite = true;

                               

                              myXml.onLoad = function(success) {
                                  for (i=0; i<=myXml.childNodes.length; 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;

                               

                                  }
                              };

                               

                              myXml.load("config.xml");

                              • 12. Re: load image
                                itgate.ir Level 1

                                thanks

                                it's work very well by this code

                                 

                                 

                                 

                                can you tell me what the last prolbems ?

                                • 13. Re: load image
                                  kglad Adobe Community Professional & MVP

                                  i used _root.targetMC when i should have used targetMC

                                  1 person found this helpful
                                  • 14. Re: load image
                                    itgate.ir Level 1

                                    thanks a lot

                                    if it's not a problem , i am a new question .

                                    i want to set an event or link per moviclip ,can you tell me what i do ?

                                    • 15. Re: load image
                                      kglad Adobe Community Professional & MVP

                                      you should start a new thread explaining what you want.  for example, you might want your movieclip to open a html file when it's clicked.

                                      • 16. Re: load image
                                        itgate.ir Level 1

                                        yes

                                        i want clicked the icons , then run the html address that write in the xml file .

                                        • 17. Re: load image
                                          itgate.ir Level 1

                                          i add this code for linked the icons to the address page , but not work

                                           

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

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

                                          }

                                           

                                          can you help me ?

                                          • 18. Re: load image
                                            kglad Adobe Community Professional & MVP

                                            start a new thread.