A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: -=-text fade in and out button-=-

  1. #1
    Its easy to make a text fade. Its also easy to make a button text fade when you mouse over it. However would you make the button reverse fade when youi take the mouse off of it. Putting the reverse frames in a seperate movie clip and roll_out goto-->frame_name didnt work. Any ideas?

  2. #2
    Senior Member
    Join Date
    Mar 2001
    Posts
    285
    Why not create a fade function which makes use of the setInterval command

    function fFade(direction){
    if(direction=="up"){
    clearInterval(fButtonFadeDown)
    fButtonFadeUp = setInterval (function () {
    if(mcButton._alpha <100){
    mcButton._alpha ++
    } }, 10);

    }
    else if (direction=="down"){
    clearInterval(fButtonFadeUp)
    fButtonFadeDown = setInterval (function () {
    if(mcButton._alpha >50){
    mcButton._alpha --
    }}, 10);
    }
    }

    Then on your button:

    on(rollOver){
    _root.function fFade(up)
    }
    on(rollOut){
    _root.function fFade(down)
    }



  3. #3
    Thank you for your help, however, I have a question.
    Say, the button is in scene1, in the first frame of the movie... Should I put the fade scipt in frame_1 and then place the button script on the button itself?
    I think I tried this and it didnt work, because I dont have the actionscript in the right place. hmmm....


  4. #4
    bump.

  5. #5
    And should I replace mcButton the symbol name of the button or just leave the code as is? Thank you for your time!

  6. #6
    When debugging it says this.

    cene=Scene 1, Layer=Layer 1, Frame=1: Line 2: Expected a field name after '.' operator.
    _root.function fFade(up)

    Scene=Scene 1, Layer=Layer 1, Frame=1: Line 3: '{' expected
    }

    Scene=Scene 1, Layer=Layer 1, Frame=1: Line 4: on handlers may not nest within other on handlers
    on(rollOut){

    Scene=Scene 1, Layer=Layer 1, Frame=1: Line 5: Expected a field name after '.' operator.
    _root.function fFade(down)

    Scene=Scene 1, Layer=Layer 1, Frame=1: Line 6: '{' expected
    }

    Scene=Scene 1, Layer=Layer 1, Frame=1: Line 4: Statement block must be terminated by '}'
    on(rollOut){

    Scene=Scene 1, Layer=Layer 1, Frame=1: Line 7: Syntax error.

    Scene=Scene 1, Layer=Layer 1, Frame=1: Line 1: Statement block must be terminated by '}'
    on(rollOver){

    Scene=Scene 1, Layer=Layer 1, Frame=1: Line 7: Syntax error.

  7. #7
    Senior Member
    Join Date
    May 2002
    Posts
    110
    Put the function script on frame 1 of scene 1...then put the button script on the buttons. Those output errors probably means u didnt copy and paste the code properly.

    Alternatively, you could make a movie clip with a button inside and put this code on the MC:
    Code:
    onClipEvent (enterFrame) {
        if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
            this.nextFrame();
        } else {
            this.prevFrame();
        }
    }

  8. #8
    Senior Member
    Join Date
    Mar 2001
    Posts
    285
    Sorry, change


    on(rollOver){
    _root.function fFade(up)
    }
    on(rollOut){
    _root.function fFade(down)
    }


    to

    on(rollOver){
    _root.fFade("up")
    }
    on(rollOut){
    _root.fFade("down")
    }

  9. #9
    I already had figured out another way of doing it that is pretty easy, however they way both of you told me to due it, were much easier. Thanks for the help. I need tos pend some time going through some tutorials perhaps and learn more, when I have time!

  10. #10
    Senior Member
    Join Date
    Mar 2001
    Posts
    285
    alhim - It's a really good idea to get into the habit of programming with functions for just about everything you do with Flash. This is generally the way advanced programmers work.

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