A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: fade array of mcs after all mcs alpha is 100

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    2

    fade array of mcs after all mcs alpha is 100

    I have ten movie clips on stage.
    Alpha is 0.
    When you rollOver each mc, each mc alpha goes to 100 and stays 100.

    i would like all mcs alpha going to 0 once all mcs alpha is 100.

    import caurina.transitions.Tweener;
    import flash.filters.GlowFilter;

    I am using this code for the fading out part but does not seem to work and gives me current_mc alpha = undefined.

    Been working on this for over a week, if anyone knows how to solve it, it would be greatly appreciated.

    var btnArray:Array = new Array(btn1_btn, btn2_btn, btn3_btn);

    var i = 0;
    var current_mc;
    var all_alphas_are_100 = true;
    for (i=0; i< btnArray.length; i++){
    current_mc = root[btnArray[i]];
    trace ("current_mc alpha : " + current_mc._alpha)
    if (current_mc._alpha != 100){
    all_alphas_are_100 = false;
    }
    };

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Code:
    root[btnArray[i]]
    that is wrong, because when you put the instance name in your Array, if an object by that instance name is found, that object's full path is instead stored in your array, and that's probably what's happening, yet you are using dynamical object reference, which eliminates the otherwise working code. In layman's terms, change the above line to this:

    Code:
    btnArray[i]
    Just for the heck of it, I wrote my own version

    Actionscript Code:
    var btnArray:Array = new Array(btn1_btn, btn2_btn, btn3_btn);

    var i;
    var alphaSpeed = 5; // speed of alpha fading

    for (i=0; i< btnArray.length; i++){
        btnArray[i]._alpha = 0;
        btnRollover(btnArray[i]);
    };

    function btnRollover(btn){
        btn.onRollOver = function(){
            delete this.onEnterFrame;
            this.onEnterFrame = function(){
                if(this._alpha < 100){
                    this._alpha += alphaSpeed;
                } else {
                    delete this.onEnterFrame;
                    this._alpha = 100;
                    var a = 0;
                    for(i=0;i<btnArray.length;i++){
                        if(btnArray[i]._alpha == 100){
                            a++;
                        }
                    }
                    if(a == btnArray.length){
                        fadeAll();
                    }
                }
            }
        }
    }

    function fadeAll(){
        for(i=0;i<btnArray.length;i++){
            btnFade(btnArray[i]);
        }
    }

    function btnFade(btn){
        btn.onEnterFrame = function(){
            if(this._alpha > 0){
                this._alpha -= alphaSpeed;
            } else {
                delete this.onEnterFrame;
                this._alpha = 0;
            }
        }
    }
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    2
    Wow. Thank you thank you. You made my day (and tomorrow too!)

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