dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: unLoad xml...

  1. #1
    Junior Member
    Join Date
    Nov 2002
    Posts
    6

    unLoad xml...

    I have four photo galleries within a web page, each is loaded by using xml and that works fine but when I then click to go to my home page for example, and out of the gallery pages, the last xml photo gallery I tested appears on the home page!!!
    How do I unload the xml photo gallery so that it does not stay on the other pages within my web site?
    Please help... getting very dispondent.

  2. #2
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    I would load each into child clip that when you back out to the home section can be completely removed from the stage. I wouldn't even rely on unLoadMovie commands but rather remove it's instance completely. If they go forward from home (however your timeline is setup)...the clips are placed...the galleries load...if they back out..the clips are removed from the stage and they don't exist. Make sense?

  3. #3
    Junior Member
    Join Date
    Nov 2002
    Posts
    6
    Thanks Chris, I tried the unLoad code in AS before I posted but with no luck; I'm completely new to Flash 8 and xml and obviously finding it confusing... I have no idea how to create or use child clips, could you please suggest where to start.
    Thanks in advance.

  4. #4
    Junior Member
    Join Date
    Nov 2002
    Posts
    6
    Could you please explain what you mean by a child clip and how to delete them?

  5. #5
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    okay...let's try one from scratch.....

    Create a new movie 500x500 with a keyframe on frames 2 and 3. Put stop commands on frames 2 and 3.

    On frame 1 put nothing at all. Leave it empty.

    On frame 2 place a button with an instance name of "load_btn" and a label of "Load". Place this as the script for that button:

    Code:
    on(press){
    _root.gotoAndStop(3);
    }
    On frame 3 place another button with an instance name of "unload_btn", a label of "Unload" and for it's click handler use this script:

    on(press){
    _root.gotoAndStop(2);
    }

    Also on frame 3 create a textfield with an instance name of "mydata". Make it a dynamic textfield. Make it whatever width/ height /font you want as long as it doesn't cover the "Unload" button. Now right click that textfield and "Convert to Symbol" (type movie). You just tucked that textfield into a child clip. Name the instance name whatever you want. Then double click the symbol so you enter it's timeline (every clip has it's own timeline) and place this script on frame 1 in the actions panel:

    Code:
    myXML = new XML();
        myXML.ignoreWhite = true;
        myXML.onLoad = function(success) {
            if (success) {
          mainItem = myXML.firstChild.childNodes;
          mydata.text = mainItem[0].childNodes[0].firstChild.nodeValue;
    
    }
    }
    myXML.load("castle.xml");
     
    stop();
    Now create the "castle.xml file for my example:

    Code:
    <main>
    	<item>
    		<title>Isn't XML fun?</title> 
    		</item>
    	</main>
    Upload both to your server and run it.


    What happens is you completely remove the child from the stage in frame 2 and place it back in frame 3. Everytime it's placed it reads the xml so it's always current. If you are running multiple xml objects you will want to learn this anyway as it's the most effective way to smoke it and load it at will. The timeline and effectively utilizing it can allow you to gain more control over what is happening at any given time. Cool?
    Last edited by Chris_Seahorn; 08-29-2006 at 06:34 AM.

  6. #6
    Junior Member
    Join Date
    Nov 2002
    Posts
    6

    child clips, etc...

    Thanks Chris, you obviously have spent some time sorting that out and its very much appreciated; I'm going to try it out now.

  7. #7
    Junior Member
    Join Date
    Nov 2002
    Posts
    6
    Just went through your tutorial and its works perfect, again thanks for that! That's also improved my learning curve, excellent tutorial!

  8. #8
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Well...thanks for that! I notoriously stink at tutorials...I'm a code man and never had the talent for tutes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center