1 Reply Latest reply on Jun 21, 2006 1:27 PM by Rothrock

    set RGB issue

    RobGraham
      Howdy:

      I'm picking away at a thorny problem that may have an obvious answer that is eluding me. I'm trying to create an object generator that randomly changes the size, speed and color of objects each time it cycles. I'm currently unable to get the object to change colors even when I use a script that is working perfectly when I place the script in a button instead on the Clip event.

      For example:

      on (release) {
      var bubbleColor = new Color("bubble1");
      bubbleColor.setRGB(Math.random()*0xFFFFFF);
      }

      does what I want it to...everytime the button gets pressed the object changes to a random color. However, when I enter the same script into a movieClip

      onClipEvent (load) {
      //position bubble in the stage
      this._x = Math.random()*100+100;
      this._y = 600+100;
      //set bubble size
      var scale = (Math.random()*50+10);
      this._xscale = scale;
      this._yscale = scale;
      //set rising speed of bubble
      var speed = (Math.random()*5+5);
      //set bubble color
      var bubbleColor = new Color("bubble1");
      bubbleColor.setRGB(Math.random()*0xFFFFFF);
      }

      all of the other parameters change as designed but the color stays the same. I've added a button to the frame as a test and that changes the object color when clicked on.

      So my main question is, does the setRGB code not work with a movieClip event and, if not, is there an alternative way to do this?

      Thanks in advance,

      Rob Graham
        • 1. Re: set RGB issue
          Rothrock Level 5
          Well every time your movieclip is created loaded on the stage is it called bubble1?

          Since your onClipEvent is attached to the movie you are trying to change I think the bubble color line should be:

          var bubbleColor=new Color(this);

          That should do it. I think.