In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: alpha boosting on children

Get Adobe Flash player
by ExciteMike2 03 May 2010
    Embed
/**
 * Copyright ExciteMike2 ( http://wonderfl.net/user/ExciteMike2 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/qFfa
 */

// forked from grapefrukt's alpha boosting on children
package {

    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.events.Event;
    
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            
            var b:Shape = new Shape;
            b.graphics.beginFill(0x333333);
            b.graphics.drawRect(-50, -50, 100, 100);
            addChild(b);
            
            var s:Sprite = new Sprite;
            s.graphics.beginFill(0xff00ff);
            s.graphics.drawRect(-75, -75, 100, 100);
            addChild(s);
            
            var c:Shape = new Shape;
            c.graphics.beginFill(0x00ff00);
            c.graphics.drawRect(-25, -25, 100, 100);
            s.addChild(c);
                        
            addEventListener(Event.ENTER_FRAME, function():void{
               s.rotation += 4;
               s.alpha = 0.6 + (0.4 * (Math.sin(s.rotation * Math.PI / 180.0)));
               c.alpha = 1 / s.alpha;
            });
            
            x = 250;
            y = 250;
            
            // INTERESTING PART -----------------------
            // c is a child of s!
            s.alpha = .5;
            c.alpha = 1 / s.alpha;
            // END OF INTERESTING PART ----------------
        }
    }
}