7 Replies Latest reply on May 10, 2010 12:23 PM by kglad

    Loading xml data inside a movie clip

    lilizblacklb

      In the movie clip im doing i have few animation and transitions in movie clips. When some movie clips are click the open a text information and that text is the dynamic text that i want to load the xml file that havethe information to be displayed.

       

      i tried this code but it doesnt work

       

      var movieClipName=this._name
      var myXML = new XML();
      myXML.onLoad =function(sucess) {
          if (sucess) {
              trace(this);
      }
      }
      myXML.load ("mri.xml");
      trace(myXML);

       

       

      How ever if i place the dynamic text on the root and this code it does work. The issue here is that i need it to load when the movie clip of the text is loaded in the scene. i heard something about specifying inside the xml object the movie clip name but i couldnt understand a thing the guy tried to explain.

       

      I can send the source files if needed to undestand more. the preview of the page is in here : http://quadranglepr.lbstudiopr.com. When you click the MRI image a text field will appear saying loading... that where the xml file should load.

        • 1. Re: Loading xml data inside a movie clip
          kglad Adobe Community Professional & MVP

          that will work if it executes and the path/name to mri.xml is correct.

           

          the xml code has nothing to do with movieClipName or any movieclip being clicked, however.

          • 2. Re: Loading xml data inside a movie clip
            lilizblacklb Level 1

            When you test the movie you can see that in the output you can see the xml

            load but in the actual preview no text is display in the movie. I tried

            putting the direct path from server and the mri.xml on the root folder the

            swf is and its not displaying any text in the dynamic text placed in the

            movie clip.

             

            I placed the action inside the movie clip the dynamic text is or should I

            put it in the root?

            • 3. Re: Loading xml data inside a movie clip
              kglad Adobe Community Professional & MVP

              (i don't usually download and correct files unless i'm hired.  so, your description(s) will be needed.

               

              that said, if your onData trace is working and text is not appearing in your textfield either:

               

               

              1.  you're assigning text at the wrong time (ie, before loading is complete) or

              2.  you have an incorrect path/instance name  to your textfield or

              3   text assignment is occurring correctly but you're not seeing it for a variety of reasons.

               

               

              so, to find and correct your problem, you should:

               

              1.  assign text in your onData handler or at least make sure that handler executes before your button is clicked.

              2.  use the trace() function to find the correct path/instance name to your textfield

              • 4. Re: Loading xml data inside a movie clip
                lilizblacklb Level 1

                Ive tried adding

                 

                var myXML:XML = new XML();

                 

                myXML.ignoreWhite = true;

                 

                myXML.load ("mri.xml");

                 

                myXML.onLoad =function(sucess) {

                 

                    if (sucess) {

                 

                        trace

                (myXML.firstChild.firstChild.childNodes[1].attributes.mri);

                 

                    }else {

                 

                        trace("ERROR LOADING XML");

                 

                    }

                 

                }

                 

                 

                But it stills appear in the output windows instead the dynamic textfield. Plus the output nows says undefined. I also tried

                 

                var myXML:XML = new XML();

                 

                myXML.ignoreWhite = true;

                 

                myXML.load ("mri.xml");

                 

                myXML.onLoad =function(sucess) {

                 

                   if (sucess) {

                 

                    trace (this)

                 

                    this= myXML.firstChild.firstChild.firstChild.childNodes[1].attributes.mri;

                 

                    }else {

                 

                        trace("ERROR LOADING XML");

                 

                    }

                 

                }

                 

                But it only shows

                 

                <?xml version="1.0"?> <myxml />

                 

                in the output window and nothing in the dynamic field where the text should be.

                 

                The instance name for my dynamic text is mytext

                 

                 

                This is what my xml file says

                 

                <?xml version="1.0"?>

                 

                <myxml>

                 

                <info name=mri> Sample text to appear in text field</info>

                 

                </myxml>

                • 5. Re: Loading xml data inside a movie clip
                  kglad Adobe Community Professional & MVP

                  you have a malformed xml file.  use:

                   

                   

                  <?xml version="1.0"?>

                   

                  <myxml>

                   

                  <info name="mri"> Sample text to  appear in text field</info>

                   

                  </myxml>

                  • 6. Re: Loading xml data inside a movie clip
                    lilizblacklb Level 1

                    ok i used this code instead with txt instead of xml

                     

                    myData = new LoadVars();
                    myData.onLoad = function() {
                    mytext_txt.text = this.mytext;
                    };
                    myData.load("mri.txt");

                     

                    and it does load something in the dynamic textfield but instead of loading what the txt says it says undefined.

                    • 7. Re: Loading xml data inside a movie clip
                      kglad Adobe Community Professional & MVP

                      copy and paste mri.txt