12 Replies Latest reply on Jun 8, 2011 4:35 PM by kglad

    issues having a AS2 swf file function within another AS2 swf file

    maushooey

      I'm having issues having a swf file with a sliding navigation controlled by as2 be functional when its housed within a lookbook/sliding slideshow employing as2 that's referencing the sliding navigation swf file. the swf file with the sliding navigation functions on its own perfectly, but when it's called within the lookbook file, only the arrow/graphic controlling the navigation/movement works. the image the navigation moves doesn't function when its housed within the lookbook swf file. Both files reference the same AS folder containing a greensock folder for tweening etc. Does anyone have any idea what i'm doing wrong within the code i've provided below? I'm relatively new to AS, so any help would be greatly appreciated. thanks!

       

      AS2 for lookbook functionality:

       


      function hideIt(what)
      {
      what._visible = false;
      }
      function showSlide(direction)
      {
      if (direction == "next")
      {
      ++position;
      }
      if (direction == "prev")
      {
      --position;
      }
      if (position == _root.totalSlides)
      {
      arrowNext.enabled = false;
      gs.TweenLite.to(arrowNext, 0.35, {_alpha: 0});
      gs.TweenLite.to(arrowNext.top, 0.35, {tint: arrowOffColor});
      }
      else if (position != 0)
      {
      arrowNext.enabled = true;
      gs.TweenLite.to(arrowNext, 0.35, {_alpha: 100});
      }
      if (position == 0)
      {
      arrowPrev.enabled = false;
      gs.TweenLite.to(arrowPrev, 0.35, {_alpha: 0});
      gs.TweenLite.to(arrowPrev.top, 0.35, {tint: arrowOffColor});
      gs.TweenLite.to(arrowNext.top, 0.35, {tint: arrowOffColor});
      }
      else
      {
      arrowPrev.enabled = true;
      gs.TweenLite.to(arrowPrev, 0.35, {_alpha: 100});
      }
      gs.TweenLite.to(stripHolder, 1.2, {_x: 0 - position * imageWidth, ease: gs.easing.Cubic.easeOut});
      }
      gs.OverwriteManager.init();
      var totalSlides = 13;
      imageWidth = 886;
      arrowOffColor = "0x000000";
      arrowRollColor = "0xccd3e1";
      var isLocal;
      var loadedCount = 0;
      position = 0;
      loadedArray = ["x"];
      i = 1;
      while (i <= totalSlides)
      {
      loadedArray.push("x");
      ++i;
      }
      if (_root.imgPathList == undefined)
      {
      isLocal = true;
      imgPath = "images/";
      imgPathArray = ["slide0.swf", "slide1.swf", "slide2.swf", "slide3.swf", "slide4.swf", "slide5.swf", "slide6.swf", "slide7.swf", "slide8.swf", "slide9.swf", "slide10.swf", "slide11.swf", "slide12.swf"];
      }
      else
      {
      isLocal = false;
      imgPath = "images/";
      imgPathArray = _root.imgPathList.split(",");
      }
      arrowPrev.enabled = false;
      arrowPrev._alpha = 0;
      arrowNext._alpha = 100;
      stripHolder._alpha = 0;
      gs.TweenLite.to(stripHolder, 1, {_alpha: 100});
      arrowNext.onRollOver = function ()
      {
      gs.TweenLite.to(this.top, 0, {tint: arrowRollColor});
      }
      ;
      arrowNext.onRollOut = function ()
      {
      gs.TweenLite.to(this.top, 0, {tint: arrowOffColor});
      }
      ;
      arrowNext.onRelease = function ()
      {
      showSlide("next");
      }
      ;
      arrowPrev.onRollOver = function ()
      {
      gs.TweenLite.to(this.top, 0, {tint: arrowRollColor});
      }
      ;
      arrowPrev.onRollOut = function ()
      {
      gs.TweenLite.to(this.top, 0, {tint: arrowOffColor});
      }
      ;
      arrowPrev.onRelease = function ()
      {
      showSlide("prev");
      }
      ;
      keyListener = new Object();
      keyListener.onKeyDown = function ()
      {
      if (Key.getCode() == 39 || Key.getCode() == 40)
      {
      if (position < totalSlides)
      {
      showSlide("next");
      }
      }
      if (Key.getCode() == 37 || Key.getCode() == 38)
      {
      if (position > 0)
      {
      showSlide("prev");
      }
      }
      }
      ;
      Key.addListener(keyListener);
      i = 1;
      while (i <= totalSlides)
      {
      stripHolder.createEmptyMovieClip("slide" + i, stripHolder.getNextHighestDepth());
      _root.stripHolder["slide" + i].attachMovie("holder", "photoHolder", _root.stripHolder["slide" + i].getNextHighestDepth());
      _root.stripHolder["slide" + i].attachMovie("spinner", "spinner", _root.stripHolder["slide" + i].getNextHighestDepth());
      _root.stripHolder["slide" + i].spinner._x = 328;
      _root.stripHolder["slide" + i].spinner._y = 338;
      _root.stripHolder["slide" + i].id = i;
      _root.stripHolder["slide" + i]._x = i * imageWidth;
      var slideLoader = new MovieClipLoader();
      var slideListener = new Object();
      slideListener.onLoadInit = function (slide)
      {
      arrowNext.swapDepths(_root.getNextHighestDepth());
      arrowPrev.swapDepths(_root.getNextHighestDepth());
      ++loadedCount;
      loadedArray[slide._parent.id] = "loaded";
      slide._parent.spinner.removeMovieClip();
      if (loadedCount == totalSlides)
      {
      };
      }
      ;
      slideLoader.addListener(slideListener);
      slideLoader.loadClip(imgPath + imgPathArray[i - 1], _root.stripHolder["slide" + i].photoHolder);
      ++i;
      }
      stop();

       


      AS2 for sliding navigation (this swf is called by the cookbook main file):

       

      function updatePosition()
      {
      if (_root._xmouse > Stage.width - 1 || _root._xmouse < 1)
      {
      stopDrag();
      delete (_root.onEnterFrame);
      }
      var __reg4 = 138;
      var __reg3 = (_root.arrow._x - 19) / _root.bar._width;
      if (_global.lastPercent != __reg3)
      {
      gs.TweenMax.to(_root.container, 1, {_x: 450 - (_root.container._width - 265) * __reg3 + __reg4, ease: gs.easing.Cubic.easeOut, overwrite: true, onUpdate: optimize});
      }
      _global.lastPercent = __reg3;
      }

       


      arrow.onPress = function ()
      {
      startDrag(this, 0, 35, 505, 559, 505);
      _root.onEnterFrame = function ()
      {
      updatePosition();
      }
      ;
      }
      ;
      arrow.onRelease = function ()
      {
      stopDrag();
      delete _root.onEnterFrame;
      }
      ;