PDA

View Full Version : Change Thumbnail On Click/Press



alwaysdrifting
March 29th, 2004, 10:24 AM
Hey all,

I want to change the alpha of a thumbnail after it has been pressed, to indicate that the user has clicked it.

However, I also am changing the alpha when the user hovers over it and On Mouse Out. I've tired this:
on (press){
this._alpha -= 50;
}


What seems to happen here is that if the user clicks on it again, it can't be seen.

A problem with the below code it, On Mouse over, it fades it by 50. Then, On Click, it disappears. Then, on mouse out, it fades back to 100.

on (press){
this._alpha -= 50;
}


onClipEvent (load) {
this._alpha = 100;
}
onClipEvent (enterFrame) {
function fadeOut() {
if (this._alpha>50) {
this._alpha -= 50;
} else {
this.onEnterFrame = null;
}
}
function fadeIn() {
if (this._alpha<100) {
this._alpha += 50;
} else {
this.onEnterFrame = null;
}
}
this.onRollOver = function() {
this.onEnterFrame = fadeOut;
};
this.onRollOut = function() {
this.onEnterFrame = fadeIn;
};



}

Thanks for your help. I'd be shagged if it wasn't for this forum, you are a great help. I appreciate every reply,

Cheers,
Brian

claudio
March 29th, 2004, 10:52 AM
If you press the thumbnail, it should stay at 50% alpha? Or should it return to 100% on rollout?

alwaysdrifting
March 29th, 2004, 10:55 AM
I want it to stay at 50% alpha when pressed and always remain at 50%(A mouse over should do nothing after it's pressed) when the user is browsing that gallery. But, if they don't press it, it goes back to 100% on Mouse out.

claudio
March 29th, 2004, 11:01 AM
Okay. Replace your code for this one:
//paste the code on the main timeline
MovieClip.prototype.setAlpha = function() {
this._alpha = 100;
this.fade = function(v) {
this._alpha = v;
};
this.onPress = function() {
this.fade(50);
delete this.onRollOut;
};
this.onRollOver = function() {
this.fade(50);
};
this.onRollOut = function() {
this.fade(100);
};
};
thumb1.setAlpha();//thumb1 is the instance name of your mc

alwaysdrifting
March 29th, 2004, 03:15 PM
Claudio: I can't seem to get this to work. I've been messing around with it but nothing. Any advise?

Cheers

mlk
March 29th, 2004, 04:05 PM
claudio isnt it wiser to use hitTests instead of rollovers which behave sometimes strangely ?

alwaysdrifting
March 29th, 2004, 05:19 PM
How would I say in an if statement, if not this.onPress?

if (this._alpha<100 && this.onPress) {
this._alpha += 50;
}

Basically, I want to say. If the alpha is less than a 100 and it isn't pressed, do....

Cheers

imported_mucho
March 29th, 2004, 05:29 PM
Hi Always,

I just tried it in a clip....you prolly didn't set your thumb to a movie clip (that is what "mc" means ) check out the fla.

cheers,

m.

alwaysdrifting
March 29th, 2004, 05:33 PM
Thanks a million,

My problem was that I had that code in the MC called thumb1. Cheers for helping me

claudio
March 29th, 2004, 09:39 PM
@mlkdesign:
In this case i think its easier and better to use rollover and rollout events.

@alwaysdrifting:
welcome :)