A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Dynamic Alpha Fade Help

Hybrid View

  1. #1
    Member
    Join Date
    Aug 2000
    Posts
    44
    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

  2. #2
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    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]

  3. #3
    Member
    Join Date
    Aug 2000
    Posts
    44
    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?

  4. #4
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    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

  5. #5
    Member
    Join Date
    Aug 2000
    Posts
    44

    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

  6. #6
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    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.

  7. #7
    Member
    Join Date
    Aug 2000
    Posts
    44

    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]

  8. #8
    President, save the
    New Zealand dollar foundation

    Join Date
    Jun 2000
    Posts
    1,743
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center