I'm not very good at all in action script, that's why this may sound like a rather dumb question...
I have to make a project where people can colorize different parts of a seat individually.
So I have 30 buttons of different colors for the gallows and another 30 buttons for the armrest.
The seat image is kind of a wireframed picture.
When one clicks on red for the armrest for example the armrest shall be covered by the fabric in the red color by using a shape tween or maybe by working with a mask.
Now I do not really want to make 900 (30x30) tweens and was wondering if this can be done with actionscript.
I found out how to change a color with actionscript by using the "mycolor set RGB" script, but I could not find anywhere if this can work together with an animation.
Are you refferring to an actionscripted color fade? Maybe something like........
code:
doTween = function () {
// t will go from 0 to 1 over the time specified by this.dur (duration)
var t = (getTimer()-this.startTime)/this.dur;
if (t>1) {
t = 1;
delete this.onEnterFrame;
}
var r = t*this.r2+(1-t)*this.r1;
var g = t*this.g2+(1-t)*this.g1;
var b = t*this.b2+(1-t)*this.b1;
// trace(r + ", "+ g + ", " + b);
this.clr.setRGB((r << 16)+(g << 8)+b);
}
MovieClip.prototype.beginColorTween = function(r1, g1, b1, r2, g2, b2, duration) {
this.r1 = r1;
this.g1 = g1;
this.b1 = b1;
this.r2 = r2;
this.g2 = g2;
this.b2 = b2;
this.dur = duration;
this.startTime = getTimer();
this.clr = new Color(this);
this.onEnterFrame = doTween;
}
// transform movieclip 'mc' from red to green over 4 seconds
_root.onMouseDown=function(){
mc.beginColorTween(100, 100, 255, 255, 100, 0, 2*1000);
}
onMouseDown events are run whenever the mouse button is pressed, regardless of the object the you attach it to.
You need to use onPress or onRelease if you want the event to occur when a particular object is clicked on.
i.e.
_root.btn.onRelease = function(){
www.lexicon-design.co.uk
If we aren't supposed to eat animals, then why are they made of meat?
If Vegetarians like animals so much, why do they eat all their food?
I didn't realize anything happened as my MC was set to Alpha 0, because I actually wanted the MC be totally transparent at first and then be filled with color. Can I change lines in this script in order to do so? (Maybe the r1,g1,b1 make it alpha=0??)
Also, is there a possibility in AS that the color will not only fade in but also wipe from the bottom to the top.
Should look like the transition in: Timeline effects>Transform/Transition>Transition (clicking on Wipe and Fade)
Actually if the Wipe function can be done with AS the MC does not even have to be transparent, I think.
I only want it to be transparent so one can see what's beneath it. Beneath it is a wireframed chair which shall be covered by leather in the appropriate color when clicking on a button. Hope this makes any sense?
This little script was my first venture into time based animation and was written by Jbum.
Thats pretty cool. You got a dynamic one? I'd like to apply it to a few clips.
The script uses prototype inheritance to make it very dynamic. It can be used just like the built in play() or stop() methods. To control more than one movieclip, just assign a new movieclip to the function......
The first six parameters of the function are the rgb color values to start and end with. Manipulate those values to achieve different color fades. You can open the Flash color mixer to see the RGB value of any color.
As for the wipe effect,....... you could use the function in combination with a mask to simulate a wipe effect.
Ok, with that said, there are other options available for color fades. With Flash8, the bitmap data class has some interesting color options. The built in easing classes also offer color fades. And last but not least, the laco tween class is another easing class that offers color manipulation. The first two can be found inside flash. Do a google search to find the laco tween class.