flash actionscript:
Hello, The actionscript below blends 3 RGB colors as applied to a symbol. This is not my script, I adapted it from ones that I found searching the web. I would like to learn how to pause this code for a specificed number of seconds on the middle color. Is this possible? Sorry about all the code! Thank you for any help, Richard // PART 1: blendRGB uses this Number prototype // converts a (hex) number to r,g, and b. Number.prototype.HEXtoRGB = function(){ return {rb:this >> 16, gb:(this >> 8) & 0xff, bb:this & 0xff}; }; Color.prototype.blendRGB = function(c1,c2,t){ if (arguments.length == 2){ t = c2; c2 = this.getRGB(); } if (t<-1) t=-1; else if (t>1) t=1; if (t<0) t=1+t; c1 = c1.HEXtoRGB(); c2 = c2.HEXtoRGB(); var ct = (c1.rb+(c2.rb-c1.rb)*t) << 16 | (c1.gb+(c2.gb-c1.gb)*t) << 8 | (c1.bb+(c2.bb-c1.bb)*t); this.setRGB(ct); return ct; }; // PART 2: array of colors to cycle through colorSeletction = [0xFFFFFF, 0xFF9900, 0xFFFFFF]; // value to determine tweening between // 2 colors. 0 is fully the first color // 1 is fully the second color colorTween = 0; // speed for how fast the tween will progress, smaller the number slower the tween tweenSpeed = .10; // color object to control the face movieclip textColor = new Color(text); // enterFrame to handle face's color blend text.onEnterFrame = function(){ // increase tween by speed colorTween += tweenSpeed; // check to see if the color tween has passed // 1 or 0, if so, offset it to be back in // range and shift the elements in the array // to allow for a blend with a new color if (colorTween > 1){ colorTween--; colorSeletction.push(colorSeletction.shift()); }else if (colorTween < 0){ colorTween++; colorSeletction.unshift(colorSeletction.pop()); } // use blend RGB to blend between the first two // elements in the color array. The previous if // statements keeps them changing when the color // tween reaches the end of a tween (1 or 0) textColor.blendRGB(colorSeletction[0], colorSeletction[1], colorTween); };
you could e.g. use the setInterval() function to stop the script and continue processing it after a given interval (of course you also have to clear the interval after the first call), or you could use the getTimer() function in combination with a loop that runs as long as the timer is smaller than a certain value. Regards, Paul
Don't see what you're looking for? Try a search.
|