0 Replies Latest reply on Nov 20, 2006 9:46 AM by fatguy13

    Loading external data using XML

    fatguy13
      Hello can any one give me a hand...

      I making an application for our architecture that will be able to load images using an external XML file that can be updated rather quick when we go to meet other clients to show them our work...

      Here are my issues:::

      I have two nav systems a main nav and a sub nav


      inside the subNav_mc I have 5 more movie clips labels sub0_mc - sub4_mc

      I also have a thumbNail_mc which contains 10 thumb nail movieclip they are labels
      th0_mc - th9_mc

      on the main stage sits a empty movie clip called mainPhoto_mc

      Besides that it does not work the xml does not populate the strip and the subNav onRelase function does not work either...

      here is the .as code::

      /*----------------------------------------------------------------
      variable declarations
      ----------------------------------------------------------------*/
      var photos_xml:XML;

      //I have added these two var for the large movieclip loader
      var photoLoader_mcl:MovieClipLoader;
      // have created to use in cae I decide to use it in the transition for the main photo
      var photoLoaderListener:Object;
      //created transition manager


      /*----------------------------------------------------------------
      instantiate variables
      ----------------------------------------------------------------*/
      photos_xml = new XML();
      photos_xml.ignoreWhite=true;

      photoLoader_mcl = new MovieClipLoader();
      //created in case I decide to use a transition on the main photo
      photoLoaderListener = new Object();




      /*----------------------------------------------------------------
      functions
      ----------------------------------------------------------------*/
      this.populateThumb = function(i:Number):Void
      {
      trace("::populateThumb::");s
      //var xpos:Number =0;
      //var numofPhotos = photos_xml.firstChild.childNodes.length;
      //for (var i:Number = 0; i < numofPhotos, i++)
      //{
      var numOfGrandkids = photos_xml.firstChild.childNodes .firstChild.childNodes.length;
      for (var jj:Number = 0; jj < numOfGrandkids; jj ++)
      {
      var photoData:Object = new Object();
      photoData.photo = photos_xml.firstChild.childNodes
      .firstChild.childNodes[jj].attributes.photo;
      photoData.thumb = photos_xml.firstChild.childNodes .firstChild.childNodes[jj].attributes.thumb;
      thumbNav_mc.loadClip("linkage identifier", "thumbnail" + i + "_" + jj + "_mc", thumbNav_mc.getNextHighestDepth(), photoData);
      //Create a loadMovie for the larger Image
      photoLoader_mcl.loadClip("photos/lg/"+p_photo+".jpg",photoHolder_mc.mainPhoto_mc);
      }
      //}
      }

      /*----------------------------------------------------------------
      event handlers
      ----------------------------------------------------------------*/
      photos_xml.onLoad = function(p_success:Boolean):Void
      {
      subNav_mc.sub0_mc.onRelease = function():Void
      {
      if (p_success)
      {

      trace("::photos xml Loaded::");
      trace("::over::")
      populateThumb(0);
      }
      else
      {
      trace("::photos xm Error::");
      }
      }
      subNav_mc.sub1_mc.onRelease = function():Void
      {
      if (p_success)
      {

      trace("::photos xml Loaded::");
      populateThumb(1);
      }
      else
      {
      trace("::photos xm Error::");
      }
      }
      subNav_mc.sub2_mc.onRelease = function():Void
      {
      if (p_success)
      {

      trace("::photos xml Loaded::");
      populateThumb(2);
      }
      else
      {
      trace("::photos xm Error::");
      }
      }
      subNav_mc.sub3_mc.onRelease = function():Void
      {
      if (p_success)
      {

      trace("::photos xml Loaded::");
      populateThumb(3);
      }
      else
      {
      trace("::photos xm Error::");
      }
      }
      subNav_mc.sub4_mc.onRelease = function():Void
      {
      if (p_success)
      {

      trace("::photos xml Loaded::");
      populateThumb(4);
      }
      else
      {
      trace("::photos xm Error::");
      }
      }
      }

      photoLoaderLisetner.onLoadProgress = function(target_mc:MovieClip,bytesLoaded:Number,bytesTotal:Number):Void
      {
      trace("::onLoadProgress::");
      photoHolder_mc.mainPhoto_mc._alpha=Math.round(bytesLoaded/bytesTotal*100);
      }

      photoLoaderListener.onLoadComplete = function(p_target:MovieClip):Void
      {
      trace("::onLoadComplete::");
      var mainPhotoTransitionManager:TransitionManager;
      mainPhotoTransitionManager = new TransitionManager("mainPhoto_mc");
      mainPhotoTransitionManager.startTransition
      ({
      type:Wipe,
      direction:transition.IN,
      duration:0.75,
      easing:Regular.easeOut,
      startPoint:2,
      });
      }

      transitionListener.allTransitionsInDone = function ():Void
      {
      trace(":: allTransitionsInDone ::");

      TransitionManager.start(folderHolder_mc.mainPhoto_mc, {type:Photo, direction:Transition.IN, duration:0.25, easing: None.easeNone});
      }
      /*----------------------------------------------------------------
      run immediately
      ----------------------------------------------------------------*/
      photos_xml.load("photos.xml");

      thumbLoader_mcl.addListener(thumbLoaderListener);

      thumbLoader_mcl.loadClip("photos/sm/" + this.photo +".jpg", photoThumb_mc);

      photoLoader_mcl.addListener(photoLoaderListener);

      mainPhotoTransitionManager.addEventListener("allTransitionsInDone", transitionListener);



      thanks for the help!!!!!