PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
CS3 Help Improve my fadeIn-fadeOut code
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Help Improve my fadeIn-fadeOut code

  1. #1
    Junior Member
    Join Date
    Jul 2007
    Posts
    12

    Help Improve my fadeIn-fadeOut code

    default:
    red box//visible
    blue box//not visible
    green box//not visible

    when blue button is click//red box fades out; blue box fades in
    when green button is click// any visible box fades out and fades in the green box
    when red button is click//any visible box fades out and fades in the red box

    only one box is visible at a time

    the problem with my code is that.. it sometimes have a pause when switching from one button to another. can someone check this please.. im still noob at AS.

    Actionscript Code:
    box1._alpha = 0;
    box2._alpha = 100;
    box3._alpha = 0;
    this.bb1.bb1.onRelease = function() {
    clearInterval(fadeInterval)
    function fadeOut() {
        if ((box2._alpha>0||box3._alpha>0)) {
            box2._alpha -= 2;
            box3._alpha -= 2;
        } else {
            clearInterval(fadeInterval);
            setTimeout(startOut, 0);
        }
    }
    function fadeIn() {
        if (box1._alpha<100) {
            box1._alpha += 2;
        } else {
            clearInterval(fadeInterval);
        }
    }
    function startOut() {
        fadeInterval = setInterval(fadeIn, 5);
    }

    var fadeInterval = setInterval(fadeOut, 5);
    }
    //=============================================================
    this.bb1.bb2.onRelease = function() {
    clearInterval(fadeInterval)
    function fadeOut() {
        if ((box1._alpha>0||box3._alpha>0)) {
            box1._alpha -= 2;
            box3._alpha -= 2;
        } else {
            clearInterval(fadeInterval);
            setTimeout(startOut, 0);
        }
    }
    function fadeIn() {
        if (box2._alpha<100) {
            box2._alpha += 2;
        } else {
            clearInterval(fadeInterval);
        }
    }
    function startOut() {
        fadeInterval = setInterval(fadeIn, 5);
    }

    var fadeInterval = setInterval(fadeOut, 5);
    }
    //========================================================
    this.bb1.bb3.onRelease = function() {
    clearInterval(fadeInterval)
    function fadeOut() {
        if ((box1._alpha>0||box2._alpha>0)) {
            box1._alpha -= 2;
            box2._alpha -= 2;
        } else {
            clearInterval(fadeInterval);
            setTimeout(startOut, 0);
        }
    }
    function fadeIn() {
        if (box3._alpha<100) {
            box3._alpha += 2;
        } else {
            clearInterval(fadeInterval);
        }
    }
    function startOut() {
        fadeInterval = setInterval(fadeIn, 5);
    }

    var fadeInterval = setInterval(fadeOut, 5);
    }

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    I recommend you take a look at TweenLite for your fading needs.
    It really simplifies things.

  3. #3
    Junior Member
    Join Date
    Jul 2007
    Posts
    12
    Solved it by just adding a small code..

    thanks
    Last edited by id00bi; 07-14-2010 at 11:33 PM.

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