1 Reply Latest reply on Apr 10, 2011 10:14 PM by kglad

    swf that's embeded in another swf only works on first run

    AttaBoy2 Level 3

      If you go here

      and click on the animation link the skin at the bottom of the video is visible then fades away.  If you navigate away from animation then come back the skin isn't there. I don't know why.

       

      Here's the code for the animation swf with the parts I think are relivern in bold:

       

      import mx.video.*;

       

      var totalRecord:Number = 0;
      var intStartImage:Number = 5;
      var p:Number = 0;
      /////
      var currPos:Number = scrollFace._y;
      var scrollHeight:Number = scrollTrack._height;
      var scrollFaceHeight:Number = scrollFace._height;
      var maskHeight:Number = mask_mc._height;
      var initPosition:Number = scrollFace._y=scrollTrack._y;
      var initContentPos:Number = thumbnail_mc._y;
      var finalContentPos:Number;
      var left:Number = scrollTrack._x;
      var top:Number = scrollTrack._y;
      var right:Number = scrollTrack._x;
      var bottom:Number = scrollTrack._y + scrollTrack._height - scrollFaceHeight;
      var dy:Number = 0;
      var speed:Number = 10;
      var moveVal:Number = 0;
      var moveAmt:Number = 0;
      var contentHeight:Number;
      var scroller:Boolean;

       

      //thumbnail_mc._y = thumbnail_mc._y-6; // top of image align with top of mask
      function loadXML(loaded) {
          if (loaded) {
              xmlNode = this.firstChild;
              image = [];
              description = [];
              thumbnails = [];
              Heading  = [];
              total = xmlNode.childNodes.length;
             
              totalRecord = total;
             
              for (i=0; i<total; i++) {
                  image[i]         = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
                  description[i]     = xmlNode.childNodes[i].childNodes[1].attributes.Medium + "\n" + xmlNode.childNodes[i].childNodes[1].attributes.Size ;
                  thumbnails[i]     = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
                  Heading[i]        = xmlNode.childNodes[i].childNodes[3].attributes.Title;
                  thumbnails_fn(i);
              }
              scrollbarOnOff();
              firstImage();
          } else {
              content = "file not loaded!";
          }
      }
      xmlData = new XML();
      xmlData.ignoreWhite = true;
      xmlData.onLoad = loadXML;
      xmlData.load("galleryxml/animation.xml");
      /////////////////////////////////////
      listen = new Object();
      listen.onKeyDown = function() {
          if (Key.getCode() == Key.LEFT) {
              prevImage();
          } else if (Key.getCode() == Key.RIGHT) {
              nextImage();
          }
      };
      Key.addListener(listen);
      previous_btn.onRelease = function() {previousButton();};

       

      function previousButton():Void {
              if(intStartImage >5) {   
               intStartImage--;           
               thumbnail_mc._y += 65;
           }   
          prevImage();
      }

       

      next_btn.onRelease = function() {nextButton();};

       

      function nextButton():Void {
                  if(totalRecord >5)
          {       
              if(intStartImage < 5){intStartImage = 5;}

              if(totalRecord > intStartImage)
              {
              intStartImage++;
              thumbnail_mc._y -= 65;
              }
          }
              p++;
              contentHeight = thumbnail_mc._height + 8;
              moveVal = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
               currPos = scrollFace._y;
         
          nextImage();
      }

       

      scrollTrack.onPress = function():Void {
           if (scrollFace._y > _ymouse) {
              previousButton();
           }else{
              nextButton();
           }
      }
      /////////////////////////////////////

       

      this.onEnterFrame = function() {
          filesize = picture.getBytesTotal();
          loaded = picture.getBytesLoaded();
          preloader._visible = true;
          if (loaded != filesize) {
              preloader.preload_bar._xscale = 100*loaded/filesize;
          } else {
              preloader._visible = false;
              if (picture._alpha<100) {
                  picture._alpha += 10;
              }
          }
      };
      function nextImage() {
          if(scroller == true){
          finalContentPos = maskHeight-contentHeight+initContentPos;
          moveVal = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
          moveAmt = (contentHeight / totalRecord) / moveVal;
          currPos = (moveAmt * p + 1) + top;
                 
          if(currPos > bottom - 5){currPos = bottom - 1;}
          if(thumbnail_mc._y < finalContentPos){thumbnail_mc._y = finalContentPos;}
         
          contentHeight = thumbnail_mc._height + 8;
          if(p<total){
              if (loaded == filesize) {loadAnimation();}
              scrollFace._y = currPos;
          }
          else{
          currPos = bottom;
          p = total - 1;
          }
          }else{loadAnimation();}
      }

       

      function prevImage() {
          if(currPos < top + (moveAmt*2)){currPos = top +3;}
         
          if (p>0) {
              p--;
              loadAnimation();
          }

       

           if(thumbnail_mc._y > initContentPos){thumbnail_mc._y = initContentPos;}

           currPos -= moveAmt;

          scrollFace._y = currPos;

          if(scrollFace._y <= scrollTrack._y +4){scrollFace._y = scrollTrack._y;}
      }


      function firstImage() {
          moveVal = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
          if (loaded == filesize) {loadAnimation();}
      }


      function picture_num() {
          current_pos = p+1;
           pos_txt.text = current_pos+" / "+total;
      }

       

      scrollFace.onPress = function() {
          contentHeight = thumbnail_mc._height;
          moveVal = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
         
          startDrag(this, false, left, top, right, bottom);
              this.onMouseMove = function() {
              dy = Math.abs(initPosition-this._y);
              thumbnail_mc._y = Math.round((dy*(-1*moveVal))+initContentPos);
          };
      };

       

      scrollFace.onMouseUp = function() {
          stopDrag();
          delete this.onMouseMove;
      };

       

      function scrollbarOnOff():Void {
          if (totalRecord < 6){
          scroller = false;
          scrollFace._visible = false;
          next_btn._visible = false;
          previous_btn._visible = false;
          scrollTrack._visible = false;
          } else {
          scroller = true;
          scrollFace._visible = true;
          previous_btn.enabled = true;
          next_btn._visible =true;
          scrollTrack._visible = true;
          }
      }

       

      function loadAnimation():Void {
             
              playVideo();
              desc_txt.text = description[p];
              Heading_name.text = Heading[p];
              picture_num();
      }

       

      function thumbnails_fn(k) {
         
          thumbnail_mc.createEmptyMovieClip("t"+k,thumbnail_mc.getNextHighestDepth());
          tlistener = new Object();
          tlistener.onLoadInit = function(target_mc) {
              contentHeight = thumbnail_mc._height + 8;
              target_mc._y =(mask_mc._y+(target_mc._height+8)*k) - 8;
              target_mc.pictureValue = k; //pictureValue is a dynamic var that's created here
              target_mc.onRelease = function() {
                  p = this.pictureValue;
                 
                  this._alpha = 100;
                  if (p == 1){
                      scrollFace_y = top;
                  }else{
                  scrollFace_y = currPos;
                  }
      if (loaded == filesize) {
         
              playVideo();
              desc_txt.text = description[p];
              Heading_name.text = Heading[p];
              picture_num();
          }
              is_scroller_needed();
              nextImage();
                 
              };
              target_mc.onRollOver = function() {
                  /* new code goes here */
                  this._alpha = 60;
              };
              target_mc.onRollOut = function() {
                  this._alpha = 100;
              };
          };
          image_mcl = new MovieClipLoader();
          image_mcl.addListener(tlistener);
          image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
      }


      function playVideo():Void {
          myVideo.skin_mc._alpha = 100;
          myVideo.skin_mc._visible = true;
          _level3.logo_mc._alpha = 0;
          myVideo.skinAutoHide = false;
          myVideo.contentPath = image[p];
          setTimeout(hideSkin, 2500);
      }
      var tl:MovieClip = this;
      function hideSkin() {
          tl.onEnterFrame = function() {
              myVideo.skin_mc._alpha -= 1;
             
              if(myVideo.skin_mc._alpha <=0){
                  _level3.logo_mc._alpha = 100;
                  delete this.onEnterFrame;
                  myVideo.skinAutoHide = true;
                  myVideo.skin_mc._alpha = 100;
                  myVideo.onRollOver = function() {_level3.logo_mc._alpha = 0;}
                  myVideo.onRollOut = function() {_level3.logo_mc._alpha = 100;}
              }
          };
      }