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

Happy New YEAR!

to all of you here!


Some experiment with soundtest6 from gaina, tweensy and flupie
Work in progress...trying to get the right effect
Get Adobe Flash player
by tjoen 27 Dec 2010
/**
 * Copyright tjoen ( http://wonderfl.net/user/tjoen )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/tbkN
 */

// forked from tjoen's Starry soundtest6
// forked from gaina's soundtest6

package  
    { 
        import flash.display.Sprite;
        import flash.display.Graphics;
        import flash.events.Event;
        import flash.text.TextFormatAlign;
        import flash.text.TextField;
        import flash.text.TextFormat;
        import flash.events.MouseEvent;
        import flash.media.Sound;
        import flash.media.SoundChannel;
        import flash.media.SoundLoaderContext;
        import flash.media.SoundMixer;
        import flash.net.URLRequest;
        import flash.utils.ByteArray;
        import flash.filters.*;
        import flupie.textanim.*;
        import net.wonderfl.utils.FontLoader;   
        import caurina.transitions.Tweener;
        import caurina.transitions.properties.*;
        import net.hires.debug.Stats;
        import com.flashdynamix.motion.*;
        import com.flashdynamix.motion.guides.Orbit2D;
        import fl.motion.easing.*;
        
        [SWF(width=465,height=465,backgroundColor=0x000000)]
        public class soundSpectrum extends Sprite
        {
            public var rot:Number = 0;
            private var leftRightSpList:Array;
            private var snd:Sound;
            private var FFTswitch:Boolean = false;
            private var fil:Array = [];
            public var _canvas:Sprite;
            public var _canvasWidth:uint; 
            public var _canvasHeight:uint;
            public var outline:GlowFilter
            public var ds:DropShadowFilter;
            public var tf:TextField;
            public var _click:Boolean = false;
            public var _fm:TextFormat;

              
            function soundSpectrum() 
            {
                
            _canvas = new Sprite();
            addChild(_canvas);
            _canvas.graphics.beginFill(0x353436);
            _canvasWidth = stage.stageWidth; 
            _canvasHeight = stage.stageHeight;
            _canvas.graphics.drawRect(0, 0, _canvasWidth, _canvasHeight);
            _canvas.graphics.endFill();
            
                leftRightSpList = makeLeftRightSpList();
                
                playSound("http://www.takasumi-nagai.com/soundfiles/sound001.mp3");
                addEventListener(Event.ENTER_FRAME, onEnterFrame);
                stage.addEventListener(MouseEvent.CLICK, FFTswitcher);
                fil = [new BlurFilter(0.5, 0.5, 3)];//, new BlurFilter(0.5, 0.5, 3)];  
                //addChild(new Stats()); 
                 var fl :FontLoader = new FontLoader;
            fl.load( "Mona" );
            fl.addEventListener( Event.COMPLETE, function(ev :Event) :void {
    
            RunText();
                
            });        
            }
  
   public function RunText():void   {
                    
                var text_array:Array = new Array();
                text_array = [
                "HAPPY\nNEW YEAR!", 
                "<font size =\"+90\">Happy</font>\n2011",  
                "It's <font color=\"#FFFFFF\">wonder</font><font color=\"#FF0000\">fl</font><br>", 
                "<center><font size =\"+20\">ALL</font><br>the best<br><font size =\"+60\" color=\"#ff0000\">IN</font><br><font size =\"+10\">2011!!!</font></center>"];
                var whatText:Number = Math.round (Math.random () * (text_array.length - 1));    
                                 
                _fm = new TextFormat("Mona", getRandom(22,42), Math.random() * 0xffffff, true);
                _fm.align = TextFormatAlign.CENTER;
                
                tf = new TextField;
                tf.embedFonts = true;
                tf.autoSize = "center";
                tf.multiline = true;
                tf.defaultTextFormat = _fm;

                addChild(tf);
        
                outline = new GlowFilter();
                outline.blurX = outline.blurY = 2;
                outline.color = 0x000000;
                outline.quality = BitmapFilterQuality.HIGH;
                outline.strength = 50;
                ds = new DropShadowFilter( 4, 45, 0X000000, 1, 2.0, 2.0, 1.0, 1);

                var filterArray:Array = new Array();
                filterArray.push(outline, ds);
                tf.filters = filterArray;
                
                var splitArray:Array = new Array();
                splitArray = ["CHARS",  "WORDS", "LINES"];
            
                var anim:TextAnim = new TextAnim(tf);
                anim.htmlText = text_array[whatText];
                anim.effects = myEffect4;
                anim.mode = TextAnimMode.RANDOM;
                anim.blocksVisible = false;
                anim.split = splitArray[0];//getRandom(0,2)
                
                anim.blocksVisible = false;
                anim.x = _canvasWidth / 2 - anim.width / 4;
                anim.y = _canvasHeight / getRandom(2,4) - anim.height / 2;    
                
                
            anim.start();
            init();
            }
        
        private function myEffect(block:TextAnimBlock):void {
            block.scaleX = block.scaleY = 0;
            block.rotation = getRandom(-180,180);
            block.y = block.posY - getRandom(200,1500);
            Tweener.addTween(_canvas, { _color:Math.random()*0xFFFFFF, time:2, transition:"linear", delay:0});
            Tweener.addTween(block, { rotation:0, y: block.posY, x: block.posX, scaleX:1, scaleY:1, time:2, transition:"easeoutelastic" } );
            Tweener.addTween(block, { alpha: 0, rotation:0, scaleX:0, scaleY: 0, y:block.posY+getRandom(-1000,1000), x:block.posX+getRandom(-1000,1000), scaleX:1, scaleY:1, time:3, transition:"linear", delay:7 } );
            }
            
                  private function myEffect4(block:TextAnimBlock):void {
            block.scaleX = block.scaleY = 1;
            block.alpha = 1;
            
                var tween:TweensyGroup = new TweensyGroup(); 
                 tween.from(new Orbit2D(block, 200, 200, 40, 220, true), { degree:1440 }, 5,Sine.easeInOut,0,block);
                 
                 tween.to(block, {alpha: 1, rotation: 0, scaleX: 1, scaleY: 1, y:block.posY, x:block.posX, scaleX:1, scaleY:1}, 6, Back.easeInOut);
            
           // var tween:TweensyTimeline = Tweensy.to(block, {alpha: 1, rotation:0, scaleX:1, scaleY:1}, 5 * Math.random(), Elastic.easeInOut);
            //tween = Tweensy.from(block, {x:stage.width * Math.random(), y:stage.height * Math.random()}, 1.5, Sine.easeInOut); // Sine.easeInOut);
           // tween = Tweensy.from(new DropShadowFilter(), {alpha:0.8}, 0.5, null, 1, block);
           
            tween.onComplete = function():void{
             
                tween.to(block, {alpha: 0, rotation: 0, scaleX: 0, scaleY: 0, y:block.posY+getRandom(-1000,1000), x:block.posX+getRandom(-1000,1000), scaleX:1, scaleY:1}, 2, Back.easeInOut, 6);  
            }
          }      
        
         public static function init():void   {
            ColorShortcuts.init();
            DisplayShortcuts.init();
            FilterShortcuts.init();
        }
        
        public static function getRandom(min_num:Number,max_num:Number):Number{
            return min_num + Math.floor(Math.random() * (max_num + 1 - min_num));
        }
              
            
                    public function drawStar(g:Graphics, _x:Number=0, _y:Number=0, outer:Number=50, inner:Number=20, rot:Number=0):void
        {
            var angle:Number = rot+Math.PI/2;
            var px:Number = _x+Math.cos(angle)*outer;
            var py:Number = _y+Math.sin(angle)*outer;
            
            
            g.moveTo(px,py);
            for(var i:int=0; i<5; i++)
            {
                angle += Math.PI/5;
                px = _x+Math.cos(angle)*inner;
                py = _y+Math.sin(angle)*inner;
                //handdrawn effect ;)  g.lineTo(py,px);
                g.lineTo(px,py);
                
                angle += Math.PI/5;
                px = _x+Math.cos(angle)*outer;
                py = _y+Math.sin(angle)*outer;
                g.lineTo(px,py);
            }
        }           
            
            private function playSound(sndUrl:String):void
            {
                snd = new Sound();
                var context:SoundLoaderContext = new SoundLoaderContext(10,true);
                var req:URLRequest = new URLRequest(sndUrl);
                snd.load(req, context);
                var sndChannel:SoundChannel=new SoundChannel();
                sndChannel = snd.play(0, 5);
                
            }
            
            private function FFTswitcher(e:MouseEvent):void 
        {
            //if (FFTswitch) { FFTswitch = false; } else { FFTswitch = true;}
        }
            
            private function onEnterFrame(event:Event):void {
                var sp:Sprite=new Sprite();
                var bytes:ByteArray = new ByteArray();
                SoundMixer.computeSpectrum(bytes, FFTswitch, 0);
                var i:uint, j:uint;
                for (i = 0; i < 5; i++)
                {
                    var spList:Array = leftRightSpList[i];
                    for (j = 0; j < 256; j++)
                    {
                        sp = spList[j];
                        var rf:Number = bytes.readFloat();
                        var scale:Number = Math.max(0.5, 1 + rf * 10);
                        sp.scaleX = sp.scaleY = scale;
                        if (scale > 7){
                            init();
                            Tweener.addTween(_canvas, { _color:Math.random()*0xFFFFFF, time:1, transition:"linear"});
                         
                        }
    
                         if    (scale > 10){ 
                         RunText();   
                         }
    
    
                        if(!FFTswitch){
                            sp.y += sp.y *rf * 5 + 8;
                            
                        }else{
                            sp.y = sp.y *rf * 5 + 8;
                                 }
        
                        sp.filters = fil;

                    }
                }
            }         
                    
            private function makeLeftRightSpList():Array
            {
                var spLRList:Array = new Array();
                var circle_r:uint = 3;
                var n:uint;
                var i:uint;;
                for (n = 0; n < 2; n++)
                {
                    var spList:Array = new Array();
                    for (i = 0; i < 256; i++) {
                        var sp:Sprite = new Sprite();
                        if (n == 0) {
                            sp.graphics.beginFill(0, 0);
                            sp.graphics.lineStyle(1, Math.random()*0xFFFFFF);
                            drawStar(sp.graphics, 0, 0, Math.random()*10, Math.random()*10,Math.random()*360-Math.random()*360);
   
                            //sp.graphics.drawCircle(0, 0, circle_r);       
                        }else {
                            sp.graphics.beginFill(Math.random()*0xFFFFFF);
                            drawStar(sp.graphics, 0, 0, Math.random()*6, Math.random()*4,Math.random()*360-Math.random()*360);
                           
                        }
                        sp.graphics.endFill();
                        sp.x = stage.stageWidth/ 256 * i;
                        sp.y = 200;
                        
                        addChild(sp);
                        spList.push(sp);
                    }
                    spLRList.push(spList);
                } 
                return spLRList;
            }
        }
        
    }