View Full Version : Color trouble...
Saskia
March 22nd, 2004, 10:49 AM
Hello hello,
I'm having trouble with some scripting.
I have 2 butons...im using variables...and... on rollover...the buttons fades to magenta... on rollout... the buttons fades beack to white. What I want to do is...if you click one button...that one stays magenta...while the other one stays white... if you click the other button... the firtst button turns back to it's original state.
I've tried using only the movies but I can't get it to work...So I tried using setRGB...but... isn't it possible that... in the IF - part...I can say something as: go to original color ... or... disable the part setRGB???
Below you can see the script of one button. I'm not so good at explaning so I hope i'm not rambling here.
on (rollOver) {
but2.gotoAndPlay("magenta");
}
on (rollOut) {
but2.gotoAndPlay("white");
}
on (release, releaseOutside) {
stopxback = -1481.2;
stopxfront = 494.9;
_root.back.gotoItem(this);
_root.front.gotoItem(this);
myColorObject = new Color(_root.front.but2);
myColorObject.setRGB(0xFF0099);
_root.var2 = 1;
if (_root.var1 == 1) {
myColorObject = new Color(_root.front.but1);
myColorObject.setRGB(0xFFFFFF);
_root.var1 = 0;
}
I hope someone can help me? :te:
greetz...
}
PintSize
March 22nd, 2004, 11:39 AM
well im the other part of your movie where you have it goin to creat a new keyframe and make the button of the movie section you are at one color and then have it change when at another state of the movie. so you can have 'contact' on fram 5 and 'portfolio' on frame 10...at frame 5 have a seperat button that on frame 10
Seticus
March 22nd, 2004, 12:22 PM
Well, you can use AS, I've wrote you a script (and probably the shortest color-fader possible), just give the following code to your movieclips so use movieclips, and not buttons!!on (release, releaseOutside) {
//stopxback = -1481.2;
//stopxfront = 494.9;
colors = [255, 0, 255];
_root.button2.colors = [255, 255, 255];
//changes the colors of the other mc's, so change for each mc, the above number in the button
}
onClipEvent (load) {
col = new Color(this);
trans = new Object();
}
onClipEvent (enterFrame) {
trans.rb += (colors[0]-trans.rb)/3;
trans.gb += (colors[1]-trans.gb)/3;
trans.bb += (colors[2]-trans.bb)/3;
col.setTransform(trans);
}So the instance names of your mc's: button1, button2, button3...
P.S. loved those commercials :)
Saskia
March 22nd, 2004, 01:26 PM
Thanks for al the quick replies... i'll go and try them out...
thanks again!
Saskia
March 22nd, 2004, 02:27 PM
Hello Seticus,
I tried it but..since i'm a beginner... I don't get the results I'm after...
I've included my file for you to see so... if you could please help me some more?
I diddn't know you could do that on a movieclip...without a button.
This is the effect i'm after (see file)... but in order to now in what "chapter" of the site you at...I want to keep the colour of the button.
I've tried out some stuff on the script...but I can't cet the button to turn back to white if you click on an other button... (the clicked button has to turn pink instead)
I'm new at this so could you please help me some more? I'm really trying but I'm stuck.
this is probably a peace of cake for you...but is quite a pie for me! :-/
BTW... I see you're from Belgium...so you speak French of Dutch?
Seticus
March 22nd, 2004, 03:24 PM
Okay, i've optimized the code, add this to any frame:numberofbuttons = 5;
_root.pressed = 0;
_root.rolledover = 0;
for (m=1; m<=numberofbuttons; m++) {
mc = eval("_root.front.but"+m);
mc.num = m;
mc.col = new Color(mc);
mc.trans = new Object();
mc.onRollOver = function() {
_root.rolledover = this.num;
};
mc.onRollOut = function() {
_root.rolledover = 0;
};
mc.onRelease = function() {
_root.pressed = this.num;
};
mc.onEnterFrame = function() {
if (_root.pressed == this.num || _root.rolledover == this.num) {
this.colors = [255, 0, 255];
} else {
this.colors = [255, 255, 255];
}
this.trans.rb += (this.colors[0]-this.trans.rb)/3;
this.trans.gb += (this.colors[1]-this.trans.gb)/3;
this.trans.bb += (this.colors[2]-this.trans.bb)/3;
this.col.setTransform(this.trans);
};
}
You see the first var, if you add more buttons, change that number.
Check also the fla
I speak dutch (west-vlaams eigenlijk) and I live in Veurne :)
Seticus
March 22nd, 2004, 03:26 PM
_root. pressed will get the value 1 when you press the first button, 2 when you press the second... So that will come in handy when you will be adding you content.
Saskia
March 25th, 2004, 04:30 AM
sorry for the late reply, but I've been kinda buzzy.
Thanks a lot for the help. that works great!
Btw... what does mc mean... i've seen it everywhere...and they always talk about mc's... but.. is it short for something?
Greetz
scotty
March 25th, 2004, 04:57 AM
mc ==movieclip;)
scotty(-:
emolen
October 4th, 2005, 03:30 PM
love the script, is there a more simple way to do this since this was posted over a year ago? No worries, just wondering.
emolen
October 4th, 2005, 03:52 PM
found my ansewr
http://flashkit.com/board/showthread.php?p=3411921#post3411921
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.