12 Replies Latest reply on Oct 15, 2008 3:28 PM by lenrique21

    Loading XML into Flash

    rnjithkumar
      Hi,

      I am new to script, i need help in loading an XML List into Flash CS3.
      Please help me in this regard, thanks in Advance

      Regards
      Ranjith Kumar. Bandi
        • 1. Re: Loading XML into Flash
          Devendran Level 1
          Hi

          Read the below forum. I hope that will help to come out with a solution.

          Kirupa XML Sample
          • 2. Re: Loading XML into Flash
            rnjithkumar Level 1
            Hi Devendran,

            Thanks for your quick reqly. I tried this but i cnt able to get what i am looking.

            Eg : I have a list of - 1) Flash 2)Photoshop 3)HTML. I am looking over this list to appear in flash.

            Please help me in this.

            Regards
            Ranjith.
            • 3. Re: Loading XML into Flash
              Rnjith
              Hi ,

              I am trying to load the below XML into flash accordian in Flash CS3. Its urgent, Please help me in this regard.

              Regards
              Ranjith Kumar. Bandi
              Attach Code

              • 4. Loading XML into Flash
                Devendran Level 1
                Here is a sample imlementation of Attaching and Loading MovieClips and Images to Accordian

                in the name Give some External SWF or Image Path.
                and create one MovieClip in the name of EmptyClip and Export it for ActionScript

                and then Use the following code.
                • 5. Re: Loading XML into Flash
                  Rnjith Level 1
                  Hi Devendran,

                  In CS3 Actionscript 3.0 Accordion is not there. So i am working in Actionscript 2.0 and please guide me how to go on further.

                  If posible can u post the script in detail for XML and flash how to proceed. Sorry i was not that good at scripting. But this will be a great help from you.

                  Regards
                  Ranjith Kumar. Bandi
                  • 6. Re: Loading XML into Flash
                    Devendran Level 1
                    the sample posted by me is also AS2
                    • 7. Re: Loading XML into Flash
                      Rnjith Level 1
                      Hi Devendran.

                      Can you please explain in detail how to work on with the script given by you.

                      Regards
                      Ranjith Kumar. Bandi
                      • 8. Re: Loading XML into Flash
                        Devendran Level 1
                        Well,
                        The top few lines explains about the XML Loading

                        and the Function "addAccordianChild" will do the need full to add child to the accordian

                        Al you have to do is Put one accordian component in to the stage and name it as "myAccordian"

                        We can't load the Data directly to the Accordian, so we are giving one Empty Clip as content for the child, for this Create one Empty Movie and name it as EmptyClip and Export it for actionscript.

                        Now paste the Entire Code into the First Frame (Or the frame in which you placed the Accordian)

                        in the XML you can provide the External SWF/Image path to be loaded.
                        the attribute name should have the External link. now execute the code. It will work
                        • 9. Re: Loading XML into Flash
                          rnjithkumar Level 1
                          Hi,

                          Please find the task which i am working on -

                          I created a flash file with name lessoncounter.fla. I am working in flashcs3 and actionscript2.

                          I have a screen with 3 parts :

                          1) Application towards the left side full
                          2) Courses towards the right side top half
                          3) Lessons towards the right side bottom half.

                          I have a list of applications and each application consists of list of courses and each course consists of list of lessons. When i open my swf file screen will be with just an application accordian and it will call all list of applications from lessoncounter.xml into the application accordian towards the left side.

                          When i click on any application it will call the list of courses from lessoncounter.xml.

                          When i click on any course it will call the list of lessons from lessoncounter.xml.

                          When i click on any lessons it has to hide the Accordians of application+course+lessons and it has to call that particular lesson swf into that screen area.

                          Please find the script of Lessoncounter.xml

                          - <root>
                          - <application>
                          ShareNet
                          - <course1>
                          Site Management Tasks
                          <lesson>Introduction to the Basic Features and Navigation Principles of a ShareNet Site</lesson>
                          <lesson>Introduction to the Use of Permission Levels and Groups on ShareNet</lesson>
                          <lesson>How to Add Users to Pre-Existing Groups</lesson>
                          <lesson>How to Add a Web Part Page and Link to it from the QucikAccess Menu</lesson>
                          <lesson>How to Add a Web Part Page and Link to it from the Top Link Bar</lesson>
                          </course1>
                          - <course2>
                          Site Content Task
                          <lesson>How to Create a Picture Library and Upload Pictures to it</lesson>
                          <lesson>How to Create and Display an Announcement on a Web Part Page</lesson>
                          <lesson>How to Create a Link List and Display it on a Web Part Page</lesson>
                          </course2>
                          - <course3>
                          Web Parts
                          <lesson>How to Add and Delete Parts from your Web Part Page</lesson>
                          <lesson>How to Configure Common Web Part Options</lesson>
                          <lesson>(Option 1) : How to Set Up a Content Editor Web Part</lesson>
                          <lesson>(Option 2) : How to Set Up a Rich Content Editor Web Part</lesson>
                          <lesson>How to Add and Set Up an Image Web Part</lesson>
                          </course3>
                          - <course4>
                          Contributor Tasks
                          <lesson>Introduction to ShareNet Features</lesson>
                          </course4>
                          </application>
                          </root>

                          As you suggested i have done the work like this please suggest where i went wrong.

                          I have opened swf and created lessoncounter.fla and created a movieclip with name "EmptyClip".

                          I have created an accordian and named it as "myAccordian" and placed it on the stage and copied the below code on first frame.

                          I

                          myAccordian.doLater(this, "delay");

                          var dataXML:XML = new XML();
                          var childCount:Number = 0;
                          dataXML.ignoreWhite = true;
                          dataXML.onLoad = function(success){
                          if(success){
                          for(var i=this.firstChild.firstChild; i!= null; i=i.nextSibling){
                          addAccordianChild(i.attributes.name);
                          }
                          }

                          }
                          dataXML.load("lessoncounter.xml");

                          function addAccordianChild(value:String){

                          var resultChild = myAccordian.createChild("EmptyClip","Clip_"+childCount,{label:"CHILD - "+childCount});
                          var depthVal:Number = resultChild.getNextHighestDepth()
                          var imgHolder = resultChild.createEmptyMovieClip("ImgHolder",depthVal);
                          imgHolder.loadMovie(value);
                          childCount++;
                          }

                          But when i see the preview it was showing as child1,child2...... if i have data.xml .. when i change to lessoncounter.xml it was showing child-0 and nothing else.

                          Please help me in this regard.

                          Regards
                          Ranjith Kumar. Bandi
                          • 10. Re: Loading XML into Flash
                            Devendran Level 1
                            Then compare your XML With the DATA XML.

                            If both are having the same XML Structure, then it will work otherwise not.
                            or else you need to change the code to fetch the Data from your current XML Format.
                            • 11. Re: Loading XML into Flash
                              rnjithkumar Level 1
                              Hi,

                              I cnt able to get the solution. Can you please send me the script. I have written every thing what i want for the task in the message.

                              Regards
                              Ranjith Kumar.Bandi
                              • 12. Re: Loading XML into Flash
                                lenrique21 Level 1
                                Great templates and many other cool flash applications at:
                                http://flashden.net?ref=luke