A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [F8] Newbie help. Best way to fade everything out?

  1. #1
    Member
    Join Date
    Nov 2006
    Posts
    35

    [F8] Newbie help. Best way to fade everything out?

    Hi

    What the most CPU efficient way to fade out everything (to black) on stage, just leaving some text?

    I could select every movieclip/ object and use alpha keyframes.
    Or fade in (using alpha) a black rectangle over everything, but I think this will be quite CPU intensive.

    Is there a better way?

    Many thanks

    M

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    fading one black rectangle is more efficient than fading multiple objects
    when the fade is complete, remove all objects from the stage ( blank frame )
    to ease the CPU load,

    hth

  3. #3
    Member
    Join Date
    Nov 2006
    Posts
    35
    Thanks Modified Dog

    I was afraid of that.
    I quickly tried it and it eats CPU for afternoon snacks.
    I was hoping there would be a more efficient way, maybe with actionscript?

    How about if I turned down the brightness to -100% for each object/ mc?
    Would that be more efficient than trying to do it with transparency?

    Or tint 100% black?

    Thanks

    M

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    as long as all objects are movieclip instances, this method will set all clips to black -
    Code:
    Color.prototype.setBrightOffset = function(offset){
    var trans = new Object();
    trans.rb = trans.gb = trans.bb = offset;
    this.setTransform(trans);
    };
    
    MovieClip.prototype.setBrightness = function(offset){
    var c = new Color(this);
    c.setBrightOffset(offset);
    };
    
    function Brightness(){
    for(p in this) 
    if(typeof (this[p]) == "movieclip") this[p].setBrightness(-255);
    };
    
    b1.onRelease = function(){
    Brightness();
    }

  5. #5
    Member
    Join Date
    Nov 2006
    Posts
    35
    Great, thanks for the code Modified Dog!

    Will it fade over a certain a mount of frames, or just jump to black?

    And is it more CPU efficient than keyframing tints/ brightness or alpha?

    Many thanks!


    M

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    that code will jump to black,
    for a fade, try this code -
    Code:
    Color.prototype.setBrightOffset = function(offset){
    var trans = new Object();
    trans.rb = trans.gb = trans.bb = offset;
    this.setTransform(trans);
    };
    
    MovieClip.prototype.setBrightness = function(offset){
    var c = new Color(this);
    c.setBrightOffset(offset);
    };
    
    function Brightness(val){
    for(p in this) 
    if(typeof (this[p]) == "movieclip") this[p].setBrightness(val);
    };
    
    var iv = 0;
    
    function fader(){
    iv <= -255 ? clearInterval(fade) : iv -= 5;
    trace("fading - "+iv);
    Brightness(iv);
    };
    
    fade = setInterval(fader,100);

  7. #7
    Member
    Join Date
    Nov 2006
    Posts
    35
    Hi Modified Dog

    Great, thanks for the code!



    M

  8. #8
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    you're welcome

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