1 Reply Latest reply on Mar 13, 2008 10:28 AM by clbeech

    attachMovie() problem

      I have a problem where I'm attaching images (using AS2) which are movie clips to a clip in the main timeline.
      What happens is that when you click into one of the galleries like the "exteriors" gallery (go to the second and final image), if you change to another frame on the timeline to see another gallery, like the "interior spaces" gallery, you see the previous image in the "exteriors" gallery before it changes to the proper frame.

      the site has a layout out with one frame per "page" and ther are 4 pages that have galleries that you can click on buttons at the bottom to view the images.

      see flash site

      code for a frame a gallery is on is:
      the forward button:
      if(fr = "kit" && picCount <= 14){
      picCount = picCount + 1;
      depth = depth + 1;

      note: "fadeInk()" calls a function on an early frame. picCount is a variable for text box and it's also a variable that increments in the attach function.

      the function code is:
      function fadeInK(){
      k = holder.attachMovie(kb+picCount,kb+picCount ,depth);
      k._alpha = 0;
      k.onEnterFrame = function(){
      this._alpha += gallFadSpeed;

      As you can see, in the function, I use the variables to set the identifier and the new instance name (kb+picCount,kb+picCount ). I don't know if I'm supposed to have these in quotes. It doesn't seem like this would work. I don't know how to do this and still use variables.

      I hope someone can help me fix this glitch or at least tell me how to achieve this effect of galleries of images fading in that are controlled by buttons. If there is another way to do this I'd like to know.
      One more mysterious problem is that is you are looking at one of the gallery images, if you leave an image on the screen for about 3 minutes it just disappears. I haven't a clue. Any help is greatly appreciated as this is becoming frustrating.

      thanks for looking,
        • 1. Re: attachMovie() problem
          clbeech Level 3
          I thinks the problem here is that your not 'removing' the previous image first - and then 'adding' a new image to the 'holder' clip at the next highest depth, so in effect the images are 'stacking' constantly. additionally, it does not appear that you are 'terminating' the onEnterFrame event that you initiate in the fadeInK() method, you should have a conditional statement in there to check that when the alpha is 100% then terminate the event by calling:

          delete onEnterFrame;

          this is also mostly likely why the 'mysterious' problem occurs, because Flash will terminate a script when too many 'identical' recursions are executed. not to mention that EACH image has this transpiring continuously.

          I would suggest constructing a 'fadeOutK()' method that fades the preivious image first, and the run the fadeInK() method when the image reaches 0 alpha (use a conditional, and don't forget to terminate the loop), then add the next image to the holder at the same depth, effectively 'replacing' the one currently there.

          also - if the value of the var 'kb' is defined as a String this should work fine.