3 Replies Latest reply on Feb 24, 2010 11:38 PM by kglad

    loading external SWF into a FLA (help!!!)

    jftofer

      Hello,

      I'm building a website in AS2.  I have created a xml driven flash image gallery and am trying to get this into my website.  I'm totally new to flash.  

       

      In the website I'm building, I have a gallery button on the main page with this code:

       

      over3_btn.onRelease = function(){
          play();
          target="gallery";

       

      Which I understand that when you click it, it brings you to the gallery keyframe and play it's contents.  Then I found this code:

       

      var imageRequest:URLRequest = new URLRequest("my_gallery.swf");
      var imageLoader:Loader = new Loader();
      imageLoader.load(imageRequest);
      addChild(imageLoader);

       

      Which I pasted into the gallery keyframe, hoping that it will call up the gallery, however, this didn't work.

       

       

      Please help.  I've search far and wide and couldn't find anything that would work.

       

      Here is my the code to my gallery.  Maybe I'm coding it incorrectly?

       

      var myGalleryXML = new XML();
      myGalleryXML.ignoreWhite = true;
      myGalleryXML.load("gallery.xml");

       

      myGalleryXML.onLoad = function() {

       

      _root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x;
      _root.gallery_y = myGalleryXML.firstChild.attributes.gallery_y;
      _root.gallery_width = myGalleryXML.firstChild.attributes.gallery_width;
      _root.gallery_height = myGalleryXML.firstChild.attributes.gallery_height;

       

      _root.myImages = myGalleryXML.firstChild.childNodes;
      _root.myImagesTotal = myImages.length;

       

      _root.thumb_height = myGalleryXML.firstChild.attributes.thumb_height;
      _root.thumb_width = myGalleryXML.firstChild.attributes.thumb_width;

       

      _root.full_x = myGalleryXML.firstChild.attributes.full_x;
      _root.full_y = myGalleryXML.firstChild.attributes.full_y;

       

      callThumbs();
      createMask();
      scrolling();

       

      };

       

      function callThumbs() {
      _root.createEmptyMovieClip("container_mc",_root.getNextHighestDepth());
      container_mc._x = _root.gallery_x;
      container_mc._y = _root.gallery_y;

       

      var clipLoader = new MovieClipLoader();
      var preloader = new Object();
      clipLoader.addListener(preloader);

       

      for (i=0; i<_root.myImagesTotal; i++) {
      thumbURL = myImages[i].attributes.thumb_url;

       

      myThumb_mc = container_mc.createEmptyMovieClip(i, container_mc.getNextHighestDepth() );
      myThumb_mc._x = _root.thumb_width*i;
      clipLoader.loadClip("thumbs/"+thumbURL,myThumb_mc);

       

      preloader.onLoadStart = function(target) {
      target.createTextField("my_txt",target.getNextHighestDepth(),0,0,100,20);
      target.my_txt.selectable = false;
      };

       

      preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
      target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
      };

       

      preloader.onLoadComplete=function(target){
      target.my_txt.removeTextField();
      target.onRelease=function(){
      callFullImage(this._name);
      }
      }
      }
      }

       

      function callFullImage(myNumber) {

       

      myURL = myImages[myNumber].attributes.full_url;
      myTitle = myImages[myNumber].attributes.title;

       

      _root.createEmptyMovieClip("fullImage_mc",_root.getNextHighestDepth());
      fullImage_mc._x = _root.full_x;
      fullImage_mc._y = _root.full_y;

       

      var fullClipLoader = new MovieClipLoader();
      var fullPreloader = new Object();
      fullClipLoader.addListener(fullPreloader);

       

      fullPreloader.onLoadStart = function(target) {
      target.createTextField("my_txt",target.getNextHighestDepth(),0,0,200,20);
      target.my_txt.selectable = false;
      };

       

      fullPreloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
      target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
      };

       

      fullPreloader.onLoadComplete = function(target) {
      target.my_txt.text = myTitle;
      };
      fullClipLoader.loadClip("full_images/"+myURL,fullImage_mc);

       

      }

       

      function createMask() {

       

      _root.createEmptyMovieClip("mask_mc",_root.getNextHighestDepth());

       

      mask_mc._x = _root.gallery_x;
      mask_mc._y = _root.gallery_y;

       

      mask_mc.beginFill(0x000000,100);
      mask_mc.lineTo(_root.gallery_width,0);
      mask_mc.lineTo(_root.gallery_width,_root.gallery_height);
      mask_mc.lineTo(0,_root.gallery_height);
      mask_mc.lineTo(0,0);

       

      container_mc.setMask(mask_mc);

       

      }

       

      function scrolling() {
      _root.onEnterFrame = function() {

       

      container_mc._x += Math.cos(((mask_mc._xmouse)/mask_mc._width)*Math.PI)*15;

       

      if (container_mc._x>mask_mc._x) {
      container_mc._x = mask_mc._x;
      }

       

      if (container_mc._x<(mask_mc._x-(container_mc._width-mask_mc._width))) {
      container_mc._x = mask_mc._x-(container_mc._width-mask_mc._width);
      }

       

      };
      }

       

      Would really really appreciate any help I can get.  Thuy