24 Replies Latest reply on Jul 6, 2009 6:14 PM by kglad

    Add URL to XML Flash Images

    beko75

      Hi there,

       

      I have a xml driven flash movie where I need to be added URL from the XML file. Can someone modify it for me, please?

       

      Here are the codes:

       

       

       

       

      AS CODE:

       


      myPhoto = new XML();
      myPhoto.ignoreWhite = true;
      myPhoto.onLoad = function(success) {
          //portfolioTag = this.firstChild;
          numimages = this.firstChild.childNodes.length;
          spacing = 100;
           this.counter = 0;
          for (i=0; i<numimages; i++) {
              this.picHolder = this.firstChild.childNodes[i];
              this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
              this.thumbHolder._y = i*spacing;
              this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
              this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
              this.thumbHolder.title = this.picHolder.attributes.title;
              this.thumbHolder.main = this.picHolder.attributes.main;
              this.thumbHolder.onRelease = function() {
                  loader.loadMovie(this.main);
                  title_txt.text = this.title;
              };
          }
      };
      myPhoto.load("service.xml");

       

      >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

       

       

      XML CODE:

       

      <gallery>
      <image thmb="thumbnails/image2.jpg"/>

       

      </gallery>

       

       

      <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

       

       

      Thanks a lot,

      Beko

        • 1. Re: Add URL to XML Flash Images
          kglad Adobe Community Professional & MVP
          use:


          myPhoto = new XML();
          myPhoto.ignoreWhite = true;
          myPhoto.onLoad = function(success) {
              //portfolioTag = this.firstChild;
              numimages = this.firstChild.childNodes.length;
              spacing = 100;
               this.counter = 0;
              for (i=0; i<numimages; i++) {
                  this.picHolder = this.firstChild.childNodes[i];
                  this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
                  this.thumbHolder._y = i*spacing;
                  this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
                  this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
                  this.thumbHolder.title = this.picHolder.attributes.title;
                  this.thumbHolder.main = this.picHolder.attributes.main;
                  this.thumbHolder.onRelease = function() {
                      loader.loadMovie(this.main);
                      title_txt.text = this.title;
                  };
              }
          };
          myPhoto.load("service.xml");

           

          >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >

           

           

          XML CODE:

           

          <gallery>
          <image thmb="thumbnails/image2.jpg" title="your title" main="your url"/>

           

          </gallery>

           

           

          <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <

           

           

          Thanks a lot,

          Beko

          • 2. Re: Add URL to XML Flash Images
            beko75 Level 1

            kglad,

             

            Thanks for your quick replies again, but the url doesn't seem to work on the image : ( Any idea what might be?

             

            Thanks,

            Beko

            • 3. Re: Add URL to XML Flash Images
              Lacrymocephale

              You are asking to do your job, it's amazing. kglad don't know what you want so he tried something blindly:

               

              this.thumbHolder.main = this.picHolder.attributes.main;
                      this.thumbHolder.onRelease = function() {
                          loader.loadMovie(this.main);
                          title_txt.text = this.title;
                      };

               

              This is to load the URL of a movie into the loader. But you may want to open a new window with this URL, do do like:

               

              this.thumbHolder.main = this.picHolder.attributes.main;
                      this.thumbHolder.onRelease = function() {
                          getURL(this.main,'_blank');
                      };

               

              But you got to do your part of the job, you're the only one here knowing what you want to do with your URL.

              • 4. Re: Add URL to XML Flash Images
                kglad Adobe Community Professional & MVP

                is loader defined?

                 

                • 5. Re: Add URL to XML Flash Images
                  beko75 Level 1

                  Yes it is.

                  • 6. Re: Add URL to XML Flash Images
                    kglad Adobe Community Professional & MVP

                    don't test locally or make sure your flash files are in the trusted zone:

                     

                    http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.htm l

                    • 7. Re: Add URL to XML Flash Images
                      beko75 Level 1

                      that's why I am asking as well. I have copied and pasted the same scripts you modified for me (both AS SCRIPT and XML CODE) and it loads the image fine, but the url is not working when clicking on the image.

                      • 8. Re: Add URL to XML Flash Images
                        kglad Adobe Community Professional & MVP

                        what does the following trace function reveal:

                         

                         

                         

                        use:


                        myPhoto = new XML();
                        myPhoto.ignoreWhite = true;
                        myPhoto.onLoad = function(success) {
                            //portfolioTag = this.firstChild;
                            numimages = this.firstChild.childNodes.length;
                            spacing = 100;
                             this.counter = 0;
                            for (i=0; i<numimages; i++) {
                                this.picHolder = this.firstChild.childNodes[i];
                                this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
                                this.thumbHolder._y = i*spacing;
                                this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
                                this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
                                this.thumbHolder.title = this.picHolder.attributes.title;
                                this.thumbHolder.main = this.picHolder.attributes.main;
                                this.thumbHolder.onRelease = function() {

                        trace(this.main+" : "+loaded);
                                    loader.loadMovie(this.main);
                                    title_txt.text = this.title;
                                };
                            }
                        };
                        myPhoto.load("service.xml");

                         

                        >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >

                         

                         

                        XML CODE:

                         

                        <gallery>
                        <image thmb="thumbnails/image2.jpg" title="your title" main="your url"/>

                         

                        </gallery>

                         

                         

                        <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <

                         

                         

                        Thanks a lot,

                        Beko

                        • 9. Re: Add URL to XML Flash Images
                          beko75 Level 1

                          I have added the url " http://www.google.com " as a test.

                          When I publish the movie from flash and try to click on the image that is loaded from XML, it says:

                           

                          "http://www.google.com : undefined"

                           


                          Any idea?

                          • 10. Re: Add URL to XML Flash Images
                            Lacrymocephale Level 1

                            can you look to my message?

                            you must use getURL as what you wan't is to open the URL not loading a

                            movie from this URL.

                             

                            2009/7/6 beko75 <forums@adobe.com>:

                            I have added the url " http://www.google.com " as a test.

                            When I publish the movie from flash and try to click on the image that is loaded from XML, it says:

                            >

                            "http://www.google.com : undefined"

                            >

                            >

                            Any idea?

                            >

                            • 11. Re: Add URL to XML Flash Images
                              beko75 Level 1

                              Lacrymocephale,

                               

                              I am incorporated that same code of yours you provided me with but it's not working.

                              • 12. Re: Add URL to XML Flash Images
                                kglad Adobe Community Professional & MVP

                                that should be:

                                 


                                 

                                 

                                use:


                                myPhoto = new XML();
                                myPhoto.ignoreWhite = true;
                                myPhoto.onLoad = function(success) {
                                    //portfolioTag = this.firstChild;
                                    numimages = this.firstChild.childNodes.length;
                                    spacing = 100;
                                     this.counter = 0;
                                    for (i=0; i<numimages; i++) {
                                        this.picHolder = this.firstChild.childNodes[i];
                                        this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
                                        this.thumbHolder._y = i*spacing;
                                        this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
                                        this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
                                        this.thumbHolder.title = this.picHolder.attributes.title;
                                        this.thumbHolder.main = this.picHolder.attributes.main;
                                        this.thumbHolder.onRelease = function() {

                                trace(this.main+" : "+loader);
                                            loader.loadMovie(this.main);
                                            title_txt.text = this.title;
                                        };
                                    }
                                };

                                myPhoto.load("service.xml");

                                 

                                >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >

                                 

                                 

                                XML CODE:

                                 

                                <gallery>
                                <image thmb="thumbnails/image2.jpg" title="your title" main="your url"/>

                                 

                                </gallery>

                                 

                                 

                                <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <

                                 

                                 

                                Thanks a lot,

                                Beko

                                • 13. Re: Add URL to XML Flash Images
                                  beko75 Level 1

                                  kglad,

                                   

                                  Are you testing this as well on your end through flash to make sure it works or are you just modifying the script by heart? I do not see any progress on this; it still doesn't work.

                                  • 14. Re: Add URL to XML Flash Images
                                    kglad Adobe Community Professional & MVP

                                    what's the trace function reveal?

                                    • 15. Re: Add URL to XML Flash Images
                                      beko75 Level 1

                                      I am sorry, I do not understand the question kglad.

                                      • 16. Re: Add URL to XML Flash Images
                                        beko75 Level 1

                                        I see you are pretty skilled in this area kglad. I wonder how we fail making this work with the URL issue.

                                        Please do your best and see what we are missing on it as I badly need it.

                                         

                                        Thanks,

                                        Beko

                                        • 17. Re: Add URL to XML Flash Images
                                          kglad Adobe Community Professional & MVP

                                          what does the code in purple show in you output panel after testing in the ide?

                                          • 18. Re: Add URL to XML Flash Images
                                            beko75 Level 1

                                            again, in my XML file I have added as an example the url: "http://www.google.com"

                                            When I publish the flash movie, the image shows fine, but, when I click on the image, I get this:

                                            "http://www.google.com : undefined"

                                            • 19. Re: Add URL to XML Flash Images
                                              kglad Adobe Community Professional & MVP

                                              then loader isn't defined.

                                              • 20. Re: Add URL to XML Flash Images
                                                beko75 Level 1

                                                are you referring to the following code for the laoder as undefined:

                                                 

                                                myPhoto.load("service.xml");

                                                 

                                                If yes, the loader is properly defined, thus, the name of my xml file is already "service.xml" where it loads the image successfully.

                                                If there is anything else I am missing related to the defined loader, could you please be more specific as this is my first time I am dealing with xml dynamic content and I am raelly bad at it.

                                                 

                                                Thanks,

                                                Beko

                                                • 21. Re: Add URL to XML Flash Images
                                                  beko75 Level 1

                                                  are you referring to the following code for the laoder as undefined:

                                                   


                                                  myPhoto.load("service.xml");

                                                   


                                                  If yes, the loader is properly defined, thus, the name of my xml file is already "service.xml" where it loads the image successfully.

                                                   

                                                  If there is anything else I am missing related to the defined loader, could you please be more specific as this is my first time I am dealing with xml dynamic content and I am really bad at it.

                                                   


                                                  Thanks,

                                                   

                                                  Beko

                                                  • 22. Re: Add URL to XML Flash Images
                                                    kglad Adobe Community Professional & MVP

                                                    no.  look at the code in purple and the line below the purple code:

                                                     

                                                     

                                                    use:


                                                    myPhoto = new XML();
                                                    myPhoto.ignoreWhite = true;
                                                    myPhoto.onLoad = function(success) {
                                                        //portfolioTag = this.firstChild;
                                                        numimages = this.firstChild.childNodes.length;
                                                        spacing = 100;
                                                         this.counter = 0;
                                                        for (i=0; i<numimages; i++) {
                                                            this.picHolder = this.firstChild.childNodes[i];
                                                            this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
                                                            this.thumbHolder._y = i*spacing;
                                                            this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
                                                            this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
                                                            this.thumbHolder.title = this.picHolder.attributes.title;
                                                            this.thumbHolder.main = this.picHolder.attributes.main;
                                                            this.thumbHolder.onRelease = function() {

                                                    trace(this.main+" : "+loader);
                                                                loader.loadMovie(this.main);
                                                                title_txt.text = this.title;
                                                            };
                                                        }
                                                    };

                                                    myPhoto.load("service.xml");

                                                     

                                                    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >

                                                     

                                                     

                                                    XML CODE:

                                                     

                                                    <gallery>
                                                    <image thmb="thumbnails/image2.jpg" title="your title" main="your url"/>

                                                     

                                                    </gallery>

                                                     

                                                     

                                                    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <

                                                     

                                                     

                                                    Thanks a lot,

                                                    Beko

                                                    • 23. Re: Add URL to XML Flash Images
                                                      beko75 Level 1

                                                      then how do I define it?

                                                      • 24. Re: Add URL to XML Flash Images
                                                        kglad Adobe Community Professional & MVP

                                                        it's a target movieclip.  so, at a minimum, it must be a movieclip.  and you want to place it where you want the loaded image to appear and it's best to use an emptyMovieClip for a load-target.