4 Replies Latest reply on May 12, 2006 6:58 AM by TimSymons

    attachMovie problem

    sirwebster
      Hi, for some reason the attachMovie in this piece of code just refuses to run

      theListener.onLoadInit = function(loadedMc:MovieClip) {
      var dropShadow:DropShadowFilter = new DropShadowFilter(0, 45, 0xFFFFFF, 100, 2, 2, 255, 1);
      loadedMc.filters = [dropShadow];
      loadedMc.createEmptyMovieClip("mc_picover", 2);
      trace(loadedMc.mc_picover.attachMovie("mc_picover", "mc_over", 1));
      loadedMc.mc_picover._alpha = 0;
      loadedMc.mc_picover._width = _root.mc_slide.mc_slideshow["pic"+thePic]._width - 2;
      loadedMc.mc_picover._x = 1;
      loadedMc.mc_picover._y = 1;
      loadedMc.onRollOver = function() {
      var overTween:Tween = new Tween(loadedMc.mc_picover, "_alpha", None.easeIn, loadedMc.mc_picover._alpha, 100, 1, true);
      };
      loadedMc.onRollOut = function() {
      var overTween:Tween = new Tween(loadedMc.mc_picover, "_alpha", None.easeIn, loadedMc.mc_picover._alpha, 0, 1, true);
      };

      if (thePic < theArray.length-1) {
      thePic++
      loadPic(thePic);
      }
      };

      function loadPic(id:Number) {
      var newClip:MovieClip = _root.mc_slide.mc_slideshow.createEmptyMovieClip("pic"+id, id);
      newClip._y = 30;
      newClip._x = 13;
      newClip._x += _root.mc_slide.mc_slideshow["pic"+(id-1)]._width + _root.mc_slide.mc_slideshow["pic"+(id-1)]._x;
      theImage.loadClip(theArray[id][1], newClip);
      };


      everything else works (bar the stuff trying to reference the attached movie), any ideas? the trace just returns "undefined".

      i've checked the export for as box and the linkage is all correct, i can use the same peice of code to attach it to any other movie (dynamically created or not) but the movie i actually want to attach it to wont accept it
        • 1. Re: attachMovie problem
          TimSymons Level 1
          Not sure what you end goal is but here is what I get from your "attachMovie" portion of the code.

          You are trying to attach a dynamically created movieclip to itself...correct?

          >> loadedMc.createEmptyMovieClip("mc_picover", 2);

          This creates an empty movieclip name "mc_picover" inside the movieclip "loadedMc".

          >>trace(loadedMc.mc_picover.attachMovie("mc_picover", "mc_over", 1));

          This line then tries to attached the dynamically generated "mc_picover" to itself and rename it "mc_over".

          Just a few things to point out...

          1) you cannot use "attachMovie" on dynamically created movieclips. To use attachMovie, a movieclip must exist in the Library and have a linkage name defined. A linkage name and an instance name are not the samething.

          2) You do not have to manually attach a dyanmically generated movieclip. It is automatically a child of the movieclip that the method is applied to. That is, loadedMc.createEmptyMovieClip("mc_picover", 2); creates a movieclip with an instance name "mc_picover" and makes it a child of "loadedMc".

          3) I may have totally missed your question so, if I have, let me know.

          Tim


          • 2. attachMovie problem
            sirwebster Level 1
            • 3. attachMovie problem
              sirwebster Level 1
              hi, sorry, the confusion is my fault, i'm not trying to attach a movie to itself, that chunk of code contains some random stuff i was putting in after many hours of trying to get it to work, here's it a bit tidied up:

              function loadPic(id:Number) {
              var newClip:MovieClip = _root.mc_slide.mc_slideshow.createEmptyMovieClip("pic"+id, id);
              newClip._y = 30;
              newClip._x = 13;
              newClip._x += _root.mc_slide.mc_slideshow["pic"+(id-1)]._width + _root.mc_slide.mc_slideshow["pic"+(id-1)]._x;
              theImage.loadClip(theArray[id][1], newClip);
              };

              theListener.onLoadInit = function(loadedMc:MovieClip) {
              var dropShadow:DropShadowFilter = new DropShadowFilter(0, 45, 0xFFFFFF, 100, 2, 2, 255, 1);
              loadedMc.filters = [dropShadow];

              loadedMc.attachMovie("mc_picover", "mc_over", 1);

              loadedMc.mc_over._alpha = 0;
              loadedMc.mc_over._width = _root.mc_slide.mc_slideshow["pic"+thePic]._width - 2;
              loadedMc.mc_over._x = 1;
              loadedMc.mc_over._y = 1;
              loadedMc.onRollOver = function() {
              var overTween:Tween = new Tween(loadedMc.mc_over, "_alpha", None.easeIn, loadedMc.mc_over._alpha, 100, 1, true);
              };
              loadedMc.onRollOut = function() {
              var overTween:Tween = new Tween(loadedMc.mc_over, "_alpha", None.easeIn, loadedMc.mc_over._alpha, 0, 1, true);
              };

              if (thePic < theArray.length-1) {
              thePic++
              loadPic(thePic);
              }
              };

              the attachMovie is trying to attach a library item called mc_picover (all linkage is correct) to the mc created in the function loadPic, what i'm trying to do it create a movie, load an image into it, then add a semi-transparent mc over it which will act as the mouseover
              • 4. Re: attachMovie problem
                TimSymons Level 1
                OK. You stated that if you trace the return value of the line:

                loadedMc.attachMovie("mc_picover", "mc_over", 1);

                it returns "undefined"? I could only get this to occur in my test for the following condition.

                I had my file set to export frame for classes set to 1. I then unchecked the "Export in first frame" on the "mc_picover" library element. When I did this I got "undefined" any other time I would get the reference to the new movieclip.

                Since you said that you have the linkage setup properly, this was all I could think of that might produce the "undefined" trace you get.

                Sorry I don't have any other ideas.

                Tim