-
Hey everyone
How do i make a movie clip fade dynamically when i press a button.
Eg (Psuedo Code)
On press
Tell target BLAH BLAH to fade to alpha 0
I know its basic, but im haveing trouble!
Thanks Gang
-
President, save the New Zealand dollar foundation
Code:
// ---------------------------------------
// put this function in frame one of your main timeline
_root.alphaFade = function(ob, fadeOut) {
_root.createEmptyMovieClip("fader", 2000);
_root.fader.onEnterFrame = function() {
if (fadeOut) {
ob._alpha -= 10;
if (ob._alpha <= 0) {
this.removeMovieClip();
}
}else {
ob._alpha += 10;
if (ob._alpha >= 100) {
this.removeMovieClip();
}
}
}
}
// ------------------------------------------------------
// and call it from your buttons like this:
on(press) {
_root.alphaFade(theMovieClipYouWantToFade, true);
}
on(release) {
_root.alphaFade(theMovieClipYouWantToFade, false);
}
could be easier ways, and with more complex maths - accelleration/decelleration etc,
but this will work.
[Edited by sonwah on 04-22-2002 at 01:07 AM]
-
Originally posted by sonwah
Code:
_root.alphaFade = function(ob, fadeOut) {
_root.createEmptyMovieClip("fader", 2000);
_root.fader.onEnterFrame = function() {
if (fadeOut) {
ob._alpha -= 10;
if (ob._alpha <= 0) {
this.removeMovieClip();
}
}else {
ob._alpha += 10;
if (ob._alpha >= 100) {
this.removeMovieClip();
}
}
}
}
on(press) {
_root.alphaFade(theMovieClipYouWantToFade, true);
}
on(release) {
_root.alphaFade(theMovieClipYouWantToFade, false);
}
could be easier ways, and with more complex maths - accelleration/decelleration etc,
but this will work.
Does all this code go in the button?
-
President, save the New Zealand dollar foundation
nah, sorry should have commented that a bit better.
put the function in frame one of your main(_root) timeline.
only put the on(press){} and on(release){} bits on the button.
sorry
-
Cannot get to work
Originally posted by sonwah
nah, sorry should have commented that a bit better.
put the function in frame one of your main(_root) timeline.
only put the on(press){} and on(release){} bits on the button.
sorry
Hi Sonwah
I know im being a bit of a pain, but i cannot get it to work.
Can i send you the file and u take a look at what im doing wrong?
If not, it's all good, and thanks heaps for your help!
AJ
-
President, save the New Zealand dollar foundation
sure fire it through if you like.
what I would do first however, is make a new movie, get it going in the most simple way possible, and apply what you learn to your project.
I got a simple example going at the same time I posted that code, just to check along the way. It is quite easy, all the code you need is in my post.
-
thanks
Thanks Sonwah, to tell you the truth, im not much a prgrammer, rather I am an animator. I have used flash for about 2 years now, tinkering with basic actionscripting but really got into it as a foot into the multimedia area. Im working in 3D at the moment, using Maya for commercial projects.
Do you have a preferred email address, or should i just send it to the B vitamin one? (delete)
thanks Sonwah!
[Edited by ajspencer on 04-22-2002 at 01:36 AM]
-
President, save the New Zealand dollar foundation
yup,
but can you edit that last post and take it out again?
cheers.
I know people can get it anyway, but i don't want to make it too easy for them to spam me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|