I have a very easy question about changing the colour and shape of an object using action scripting. I've created a slider and activated control of the size using action script attached and I just need to know what script to add to make it change colour as it slides as well. Can anyone help me. Thanks shape.targetWidth = shape._width; shape.targetHeight = shape._height; shape.onEnterFrame = function() { var speed = 5; this._width += (this.targetWidth - this._width)/speed; this._height += (this.targetHeight - this._height)/speed; };
Thankyou for your quick response. I have to admit I'm a bit of a dummy when it comes to actionscript . I grabbed this script from a tutorial and it seemed to work changing the size. Could you direct me as to where I would implement this new code to change the colour as well. I need it to change colours gradually from onme colour to the next and to the 3rd colour. I can figure out the hex colours I need to make those transitions I just need to know what part of the code I need to apply it to. If you could fwd an example that would be great. Thanks Tuula
to make a decent color blend you can use the following code. just copy the code below the dotted line (which adds a new method to movieclips) and paste it into your fla before you use the new method: // to apply the color fade to a movieclip shape you would use: shape.colorFadeF(startColor,startAlpha,finalColor,finalAlpha,speedInSeconds,tran sitionSteps); // for example: shape.colorFadeF(0xff0000,100,0x00ff00,3,50); ---------------------------------- MovieClip.prototype.colorFadeF = function(rgb1, a1, rgb2, a2, speed, steps) { if (!var314159) { var314159 = 1; trA = ["ra", "rb", "ga", "gb", "ba", "bb", "aa", "ab"]; } function fadeF(mc) { if (!mc.repeatPass) { mc.repeatPass = 1; } co = mc.mcCO; tf2 = mc.tf2; tf1 = mc.tf1; steps = mc.steps; intermediateTF = mc.intermediateTF; for (var ivar = 0; ivar<trA.length; ivar++) { num = Math.floor(mc.repeatPass*(tf2[trA[ivar]]-tf1[trA[ivar]])/steps)+tf1[trA[ivar]]; intermediateTF[trA[ivar]] = num.toString(); } co.setTransform(intermediateTF); mc.repeatPass++; if (mc.repeatPass>steps) { clearInterval(mc.int); } updateAfterEvent(); } this.mcCO = new Color(this); this.mcCO.setRGB(rgb2); this._alpha = a2; this.tf2 = this.mcCO.getTransform(); this.mcCO.setRGB(rgb1); this._alpha = a1; this.tf1 = this.mcCO.getTransform(); this.steps = steps; this.speed = speed; this.intermediateTF = new Array(); clearInterval(this.int); this.repeatPass=0; this.int = setInterval(fadeF, 1000*this.speed/this.steps, this); };
Don't see what you're looking for? Try a search.
|