A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Help with using loadMovie via XML

Hybrid View

  1. #1

    Help with using loadMovie via XML

    Hi all,

    If anyone can point me to a tutorial or provide some basic script for flash and an XML file, I would be super appreciative:

    I am creating a .swf shell/projector, that will use loadMovie to load different .swf files in and out as the user sees fit. The shell will basically be a screen and 3 simple buttons: back to beginning of clip, pause clip, and advance to the next clip, i.e. loading the next .swf. Easy enough in Flash, BUT... the client would like control in the future over which movies are playing in what order, as well as adding new .swf files themselves.

    So they have proposed using an XML file that they can edit to change the order, add new .swf files, etc.

    Is there anyone who can help? What i need is script for the shell buttons that will

    A) immediately load "clip_1" by calling on the XML file to load whatever is currently being called "clip_1" (so that they can use different .swf files in the future with different names).

    B) allow the "pause" button in the shell to stop the loaded clip from playing... this is confusing to me, because if the loaded clip is actually decided by the XML, how can the shell clip communicate with it?

    C) finally, allow the "forward" button to load "clip_2" and then "clip_3" and so on, by calling up the XML and loading whatever they have designated.

    finally, i need to know the syntax in the XML that will receive the "launch clip_1, level 1" command from Flash, and then load the designated .swf.

    I cannot find any tutorials that cover this, and there aren't many threads that pop up here. Can anyone help?

    thank you so much,
    j

  2. #2
    Senior Member
    Join Date
    Feb 2006
    Location
    Portland OR
    Posts
    138
    well this might help, here is how I have worked with it before:
    A)
    //loads the XML
    var ovXML:XML = new XML();
    ovXML.onLoad = renderNav;
    ovXML.ignoreWhite = true;
    loadOV();
    function loadOV() {
    ovXML.load("pathtofile/file.xml");

    }

    //Then defines shortcut vars for the nodes
    function renderNav(OVResult) {
    if (OVResult == true) {
    //sets the paths to each node ovCluster's firstChild Node.
    //Variables for storing paths to the specific ovCluster's Nodes
    ovNode = ovXML.firstChild;
    Cluster1 = ovNode.firstChild.firstChild;
    Cluster2 = ovNode.firstChild.nextSibling.firstChild;
    Cluster3 = ovNode.firstChild.nextSibling.nextSibling.firstChi ld;
    //as many as needed.....
    //then identifies the path to the node with the movie to be loaded
    movie1 = Cluster1.nextSibling.nextSibling.firstChild.nodeVa lue;
    movie2 = Cluster2.nextSibling.nextSibling.firstChild.nodeVa lue;
    //as needed.....
    }
    //then on the action for the button
    yourButton.onRelease = function() {
    _root.content_loader_mc.loadMovie(movie1);
    }

    -------------------------------------------------------
    B) stopping the movie should be something like
    pause_btn.onRelease = function(){
    _root.content_loader_mc.stop()
    or
    movie1.stop(); ????
    }

    -------------------------------------------------------
    C) next page and prev page I've set up to navigate through the XML doc like this:

    next_btn.onRelease = function() {
    var newPageNode:XMLNode = currentPageNode.nextSibling;
    if (newPageNode) {
    currentPageNode = newPageNode;
    //pageCount = currentPageNode;
    loadPage();
    }
    };

    ----------------------------------------
    //as long as you keep your content file names in the same position in their respective nodes of the XML doc you can move through them like this:

    function loadPage() {
    var xmlPath = currentPageNode.firstChild.firstChild.nodeValue;
    var swfPath = currentPageNode.firstChild.nextSibling.firstChild. nodeValue;
    this.page_loader.unloadMovie();
    this.page_loader.loadMovie(swfPath);
    }

    hope this helps

  3. #3
    holy crap... see that is just way out of my league! i was hoping it wouldnt be that intense, but my inner child is scared to death of your child.sibling business! thanks though... cheers.

  4. #4
    Senior Member
    Join Date
    Feb 2006
    Location
    Portland OR
    Posts
    138
    yeah, that's what I said first time through but what you want to accomplish is not exactly that simple. the short version then is:
    you need to create the variables you will use (basically the path to the node with the value you want, i.e. a movie) then establish the controls for the movie (i.e. pause button). then set up a system for navigating from one movie to the next with forward and back buttons working through the XML.

    I found the tutorials at macromedia.com and communitymx really helpful in working with XML

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