View Full Version : [FMX] simple doubt in actionscript...
rasarasan
October 28th, 2002, 01:02 AM
Hi folks..
I have a movieclip which i want to gradually come into focus(vary the _alpha value) on mouseover and fade away on mouseout.
I am new to actionscript.
can anyone help.
this is my code assigned for the movieclip..
but nothing seems to happen on mouseover.
============================
on(rollover) {
if(this._alpha < 75) {
this._alpha = 75;
}
else {
this._alpha = 0;
}
}
on(rollOut) {
this._alpha=0;
}
============================
pls help me out..
thanks
lostinbeta
October 28th, 2002, 01:08 AM
Ok, to make this work you need to apply the button code to a movie clip. Yes, in MX this is luckily possible (I love this feature).
Ok, now you want to apply this code to the movie clip...
on (rollOver) {
this.onEnterFrame = function() {
this._alpha -= 5;
if (this._alpha<=0) {
this._alpha = 0;
}
};
}
on (rollOut) {
this.onEnterFrame = function() {
this._alpha += 5;
if (this._alpha>=100) {
this._alpha = 100;
}
};
}
That tells it that when you rollover the alpha should keep decreasing by 5 until it hits 0.
Then when you rollout the alpha should increase by 5 until it gets back to 100.
Why we did this on a movie clip: The onEnterFrame feature is what allows it to gradually fade. A simple rollOver function would only do the process once everytime you rolled over the button instance.
rasarasan
October 28th, 2002, 01:31 AM
Thanks a ton..
U have been so helpful in many instances..
Knowing something is different than sharing it to many,..
and u have been a great source of such stuff..
pls keep up this good work...
Loving regds:)
lostinbeta
October 28th, 2002, 01:43 AM
I am glad I could help. I enjoy passing knowledge and helping others.
Thank you for your kind words.
pom
October 28th, 2002, 08:15 AM
Nice code, Lost. But if I may add something... :beam:
on (rollOver) {
this.onEnterFrame = function() {
this._alpha -= 5;
if (this._alpha<=0) {
this._alpha = 0;
delete this.onEnterFrame;
}
};
}
on (rollOut) {
this.onEnterFrame = function() {
this._alpha += 5;
if (this._alpha>=100) {
this._alpha = 100;
delete this.onEnterFrame;
}
};
}pom :cowboy:
lostinbeta
October 28th, 2002, 11:52 AM
'DOH!!!!!!!!!
I knew it looked weird.
Thanks Ilyas.... greatly appreciated :beam:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.