0 Replies Latest reply on Dec 13, 2007 7:03 AM by cks_cropper

    Nested Movie Clips problem

    cks_cropper Level 1
      Hi, I have got two instances of a shape called "drawWindowRightBuilding" and found a script that can randomly change the colours of the movie clip. The website I got this from wasn't extremelty helpful to beginners like myself though. Currently the code will swap the colours of the movieclip (both windows) at the same time. I want it to do this with each individual window instance to make it more realistic.

      I have been looking at this code all afternoon and can't work out what to do next.

      Any help?

      Thanks



      //-----------CODE---------------

      this.createEmptyMovieClip("rbr1w1", 9);
      rbr1w1.createEmptyMovieClip();
      drawWindowRightBuilding(rbr1w1, 100,405,120);
      //new Tween(rbr1w1, "_alpha", Soft.easeOut, 100, 0, 10, true);
      rbr1w1.createEmptyMovieClip();
      drawWindowRightBuilding(rbr1w1, 100, 425, 120);

      //Code for switching lights off
      // create an instance of the Color class named cCircle
      // associated with movieclip circle_mc
      rbr1w1.cCircle = new Color(rbr1w1);

      // function to apply a random color from the colors array to the movieclip
      // associated with color instance c
      function changeToRandomColor(c:Color) {
      //var randomColor:Number = colors[Math.floor(Math.random()*colors.length)]
      rbr1w1.cCircle.setRGB(0xFBEC5D);
      }

      // assign a color instance, a default start color, and an interval to each light
      for (var ilight:String in rbr1w1) {
      // create a color instance for associated movieclip
      rbr1w1["c"+ilight] = new Color(rbr1w1[ilight]);
      // assign random color to movieclip at start
      rbr1w1["c"+ilight].setRGB(colors[Math.floor(Math.random()*colors.length)]);
      // set up the interval for each light
      // the color instance (this["c"+ilight])is passed to changeToRandomColor as a parameter
      setInterval(changeToRandomColor, 1000 + Math.random()*6000, this["c"+ilight]);
      }