20 Replies Latest reply on Aug 2, 2010 4:18 PM by kglad

    Php,xml and Flash [multiple holders]

    Tony404 Level 1

      Hi

       

      A few days ago I posted a discussion related to php,xml and Flash. I want to display my xml in flash. I got help in doing so. I now have a problem getting  the xml data that is contained in my array to be displayed on different holder movie clips.

       

      This is my code. I have been trying different configuration of the code but with no luck.

       

       

      var urls:Array = [];

       

      var index:Number;
      var index1:Number;

       

       

       

      var xml:XML = new XML();
      xml.ignoreWhite = true;
      xml.onLoad = parseXML;
      xml.load("content.php");

       

      function parseXML(){
          for(var i:Number=0;i<this.firstChild.childNodes.length;i++){
              urls.push(this.firstChild.childNodes[i].firstChild.nodeValue);
          }

       

      index=0;
      index1=1;

       

       

       

          startyourappF();

       

      }

       

       

       

      function startyourappF(){

       

      this.onEnterFrame = preloadA;

       

       

      holder.loadMovie(urls[index]);

       

      //this is me trying to get the second item in the  url in a another movie clip holder.

       

      holder1.loadMovie(urls[index1]);
      }

       

      function preloadA(){

       

      if(holder.getBytesLoaded()>50&&holder.getBytesLoaded()>=holder.getByte sTotal()){

       

      delete this.onEnterFrame;

       

      holder._width = 260.0;

       

      holder._height = 96.0;
      }

      //this should be resizing for the second holder.
      if(holder1.getBytesLoaded()>50&&holder1.getBytesLoaded()>=holder1.getB ytesTotal()){

       

      delete this.onEnterFrame;

       

      holder1._width = 260.0;

       

      holder1._height = 96.0;
      }
      }

       

       

      The code sucessfully loads the first image to holder but is unable to load the second url to holder1 and others I want to add. I spend the whole night trying out different configurations of the code but with no success.

       

      I hope you can help me. All I need is more than one image loaded from the urls array variable into multiple other holder variables.

      Hope you can help.

       

      cheers>>

        • 1. Re: Php,xml and Flash [multiple holders]
          kglad Adobe Community Professional & MVP

          do you want them all to load at the start of your app?


          • 2. Re: Php,xml and Flash [multiple holders]
            Tony404 Level 1

            Yes if possible.

             

            I have about 10 items in the url array and 10 holder video objects my flash project. My actual project is a slide show. So I would like to load the first item in my url array in holder 1 movie object and second url item in holder 2 movie object. Holder 3,4 is in the second slide and I would like to load the third item from the url array into holder 3 and fourth item in url array in holder 4 and so on.

             

             

            I do not know if loading the first 2 url array object  to holder 1 and 2 is possible then loading the 3  &  4 to holder 3 and 4 when the second slide is open.

            • 3. Re: Php,xml and Flash [multiple holders]
              kglad Adobe Community Professional & MVP

              all the holder movieclips have to exist when code executes that uses them.  so, if holder3 and holder4 are on a 2nd slide, does that slide exist when the code you showed executes?

              • 4. Re: Php,xml and Flash [multiple holders]
                Tony404 Level 1

                Yes.

                 

                What I did was copy the keyframe containing the code to the second slide. When I run the code the first image in the holder movieclip correctly displays. When I move to the second slide a error appears that informs me that "error opening url somethin something undefined".

                 

                 

                This is the url the xml flash connects to looks like:

                 

                <?xml version="1.0" encoding="iso-8859-1"?>

                 

                <images>
                <img>timlogo.png<img/>
                <img>victoria-falls.jpeg<img/>
                <img>cyber.gif<img/>
                </images>

                 

                The fisrt url appears in holder movie clip fine. The second fails to appear in holder1. With the described error.

                 

                All the slides contain the identical actionscript code to display the image.

                 

                I believe the problem is with the actionscript code but no errors appear when I run it. An error only appears when the code tries to display the second url array item in the second holder movie clip.

                • 5. Re: Php,xml and Flash [multiple holders]
                  Tony404 Level 1

                  Re: Php,xml and Flash [multiple holders]

                  Yes.

                   

                  What I did was copy the keyframe containing the code to the second slide. When I run the code the first image in the holder movieclip correctly displays. When I move to the second slide a error appears that informs me that "error opening url somethin something undefined".

                   

                   

                  This is the url the xml flash connects to looks like:

                   

                  <?xml version="1.0" encoding="iso-8859-1"?>

                   

                  <images>
                  <img>timlogo.png<img/>
                  <img>victoria-falls.jpeg<img/>
                  <img>cyber.gif<img/>
                  </images>

                   

                  The fisrt url appears in holder movie clip fine. The second fails to appear in holder1. With the described error.

                   

                  All the slides contain the identical actionscript code to display the image.

                   

                  I believe the problem is with the actionscript code but no errors appear when I run it. An error only appears when the code tries to display the second url array item in the second holder movie clip.

                   

                  • 6. Re: Php,xml and Flash [multiple holders]
                    kglad Adobe Community Professional & MVP

                    copy and paste the full error message and copy and paste the code on frame 2 that causes the error message.

                    • 7. Re: Php,xml and Flash [multiple holders]
                      Tony404 Level 1

                      Hi this is the error message.

                       

                       

                      Error opening URL "file:///C|/Users/Visionary/Desktop/timoflash/undefined"

                       

                      I thing it mite be the for loop or xml.

                       

                      Hope you can help cheers.

                      • 8. Re: Php,xml and Flash [multiple holders]
                        kglad Adobe Community Professional & MVP

                        1.  you shouldn't be using an absolute path because you'll have problems if you ever want this to work online or on someone elses computer.

                         

                        2.  you're not parsing your xml correctly.  that undefined at the end of your absolute path indicates you're using a variable to supply the file name and that variable is undefined.

                        • 9. Re: Php,xml and Flash [multiple holders]
                          Tony404 Level 1

                          Hi

                           

                          1. I don`t understand whats an ubsolute path this. After the replay I tried to load the full path of the url with no luck.

                           

                           

                          2. my xml load code and parsing seems fine. I will upload the code just in case.

                           

                          I have plans to use the flash online and you mentioned some problems I would have if I did so which I hope to understand.

                           


                          I have uploaded my flash and xml. I desperately hope you can help.

                           

                          timol.xml:

                           

                          <?xml version="1.0" encoding="iso-8859-1"?>

                           

                          <images>
                          <img>timlogo.png<img/>
                          <img>timlogo.png<img/>
                          <img>cyber.gif<img/>
                          </images>

                           

                           

                          Actionscript on the second keyframe: I added the full path as you advised.

                           

                          var urls:Array = [];

                           

                          var index:Number;
                          var index1:Number;
                          var index2:Number;

                           


                          var xml:XML = new XML();
                          xml.ignoreWhite = true;
                          xml.onLoad = parseXML;
                          //change this to the full path line
                          xml.load("C:/Users/Visionary/Desktop/timoflash/timol.xml");

                           

                          function parseXML(){
                              for(var i:Number=0;i<this.firstChild.childNodes.length;i++){
                                  urls.push(this.firstChild.childNodes[i].firstChild.nodeValue);
                              }

                           

                          index=0;
                          index1=1;
                          index2=2;

                           

                              startyourappF();

                           

                          }

                           

                           

                           

                          function startyourappF(){

                           

                          this.onEnterFrame = preloadA;

                           

                          holder.loadMovie(urls[index]);

                           

                          //The part creating the undefined error
                          holder1.loadMovie(urls[index1]);
                          }

                           

                          function preloadA(){

                           

                          if(holder.getBytesLoaded()>50&&holder.getBytesLoaded()>=holder.getBytesTotal()){

                           

                          delete this.onEnterFrame;

                           

                          holder._width = 260.0;

                           

                          holder._height = 96.0;
                          }
                          if(holder1.getBytesLoaded()>50&&holder1.getBytesLoaded()>=holder1.getBytesTotal()){

                           

                          delete this.onEnterFrame;

                           

                          holder1._width = 260.0;

                           

                          holder1._height = 96.0;
                          }
                          }

                           


                          I hope to have this run online and the xml urls coming from the server.

                           

                          Cheers. Very greatful for the help.

                          • 10. Re: Php,xml and Flash [multiple holders]
                            kglad Adobe Community Professional & MVP

                            what's the absolute address of the directory with your html and of the directory of your swf, if they are different?

                            • 11. Re: Php,xml and Flash [multiple holders]
                              Tony404 Level 1

                              When I plan to upload to my server the swf and my html will  be in the same directory.

                               

                              The first url seems to load fine but the second one is the one with the problem and the others.

                               

                              How could I fix this?

                              • 12. Re: Php,xml and Flash [multiple holders]
                                kglad Adobe Community Professional & MVP

                                you need to fix your directory structure first and you need to use relative urls.  there's no sense working on anything else because what's working now in your first frame and, if you fix the code in your 2nd frame, it too will break as soon as you upload to your server.

                                 

                                so, duplicate the directory setup you plan to use on your server and use relative urls.

                                • 13. Re: Php,xml and Flash [multiple holders]
                                  Tony404 Level 1

                                  Thanks for the reply again.

                                   

                                  What are relative urls and what can I do to fix the structure.

                                   

                                  I thought having my xml, flash and html in the same directory would worl fine inside the server. I have been using the desktop directory as a try out before uploading to the server. inside my server the flash, xml and html are in the same directory.

                                   

                                  I greatly appreciate your help.

                                   

                                  Thanks.

                                  • 14. Re: Php,xml and Flash [multiple holders]
                                    kglad Adobe Community Professional & MVP

                                    if your xml, html and swf are in the same directories and you plan to keep them in the same directories when you upload to your server, use load("timol.xml") to load your xml.  likewise remove all path info for loading anything else.

                                    1 person found this helpful
                                    • 15. Re: Php,xml and Flash [multiple holders]
                                      Tony404 Level 1

                                      Thank you.

                                       

                                      The problem mite have been because I was testing it on my desktop. So are you saying my code should then work on all keyframes when operating on the server and that the error should not appear?

                                       

                                       

                                      If so thank you very much.  I am sorry for the constant bother.

                                       

                                      I hope your last reply is a YES. for the question  about the keyframes.

                                       

                                       

                                      Cheers>>

                                      • 16. Re: Php,xml and Flash [multiple holders]
                                        kglad Adobe Community Professional & MVP

                                        i'm saying you have, at least, 2 problems and probably more.  the first that needs to be solved is not the one you want to discuss first.

                                        • 17. Re: Php,xml and Flash [multiple holders]
                                          Tony404 Level 1

                                          Hi

                                           

                                          Could you please specify. What you mean and the problems you have identified. I desperately to finish the project in the coming days.

                                           

                                           

                                          Cheers>>please specify details.

                                          • 18. Re: Php,xml and Flash [multiple holders]
                                            kglad Adobe Community Professional & MVP

                                            you need to fix your directory  structure first and you need to use relative urls.  there's no sense  working on anything else because what's working now in your first frame  and, if you fix the code in your 2nd frame, it too will break as soon as  you upload to your server.

                                             

                                            so, duplicate the directory setup you plan to use on your server and use relative urls.

                                             

                                            if your xml, html and swf are in the same directories and you plan to  keep them in the same directories when you upload to your server, use  load("timol.xml") to load your xml.  likewise remove all path info for  loading anything else.

                                            • 19. Re: Php,xml and Flash [multiple holders]
                                              Tony404 Level 1

                                              I have done so when uploading to my server. The keyframes work well. I will mark this as answered.

                                               

                                              Thanks mate>>

                                              • 20. Re: Php,xml and Flash [multiple holders]
                                                kglad Adobe Community Professional & MVP

                                                you're welcome.

                                                 

                                                (are all the problems solved?)

                                                1 person found this helpful