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

FluperTruper

Experiment with flupie, fontloader, 
tweener and filters
kinda messy but fun clicking!
@author Tjoen
Get Adobe Flash player
by tjoen 25 Jul 2010
/**
 * Copyright tjoen ( http://wonderfl.net/user/tjoen )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4bJy
 */

package
{
        
    /**
     * Experiment with flupie, fontloader, 
     * tweener and filters
     * kinda messy but fun clicking!
     * @author Tjoen
     */
    
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    import flash.display.Graphics;
    import flash.display.Sprite;
    import flash.text.TextFormatAlign;
    import flash.text.TextFormat;
    import flash.text.TextField;
    import flash.utils.setTimeout;
    import flash.filters.GlowFilter;
    import flash.filters.DropShadowFilter;
    import flash.filters.BlurFilter;
    import flash.filters.BitmapFilterQuality;
    import flash.events.Event;
    import flupie.textanim.*;
    import caurina.transitions.Tweener;
    import caurina.transitions.properties.*;
    import net.wonderfl.utils.FontLoader;
    
    [SWF(width = '465', height = '465', backgroundColor = '0xffffff', frameRate = '60')]
    
    public class TASequence extends Sprite
    {
        //if you want to embed your own font, use this in flashdevelop
        //[Embed(source='../bin/YourTtf.ttf', fontFamily='YourTtf',fontWeight="normal", mimeType='application/x-font', embedAsCFF='false')] 
        //public static var YourTtf:Class;
        
        public var _sequence:Array;
        public var _tf:TextField;
        public var _tf2:TextField;
        public var _fm:TextFormat;
        public var _fm2:TextFormat;
        public var _ta:TextAnim;
        public var _i:int = 0;
        public var i:uint;
        public var sp:Sprite;
        public var sp2:Sprite;
        public var circle_r:uint = 100;
        private var _canvas:Sprite;
        private var _canvasWidth:int;
        private var _canvasHeight:int;
        public var _c:int = 1;
        
        public function TASequence()
        {
            
            _canvas = new Sprite();
            addChild(_canvas);
            _canvas.graphics.beginFill(0xFFFFFF);
            _canvasWidth = stage.stageWidth; 
            _canvasHeight = stage.stageHeight;
            _canvas.graphics.drawRect(0, 0, _canvasWidth, _canvasHeight);
            _canvas.graphics.endFill();
            addEventListener(MouseEvent.CLICK, onClick);
            
            Wonderfl.capture_delay( 600 );            
            
            var fl :FontLoader = new FontLoader;
            fl.load( "Mona" );
            fl.addEventListener( Event.COMPLETE, function(ev :Event) :void 
            {
                
            _fm =  new TextFormat("Mona", 26, Math.random() * 0xffffff, true); //0xCACF43
            _fm.align = TextFormatAlign.CENTER;
            
            _fm2 =  new TextFormat("Mona", 18, Math.random() * 0xffffff, true); //0xCACF43
            _fm2.align = TextFormatAlign.CENTER;
            
            _tf2 = new TextField();
            _tf2.autoSize = "center";
            _tf2.multiline = true;
            _tf2.embedFonts = true;
            _tf2.defaultTextFormat = _fm2; 
            _tf2.y = stage.stageHeight - 40;
            _tf2.x = stage.stageWidth / 2;
            _tf2.text = "Click on canvas to shoot stars";
                       
            _tf = new TextField();
            _tf.autoSize = "left";
            _tf.multiline = true;
            _tf.embedFonts = true;
            _tf.defaultTextFormat = _fm;
            
            var outline:GlowFilter = new GlowFilter();
            outline.blurX = outline.blurY = 2;
            outline.color = 0x000000;
            outline.quality = BitmapFilterQuality.HIGH;
            outline.strength = 50;
            
            var bf:BlurFilter = new BlurFilter(4,4,3);
            var ds:DropShadowFilter = new DropShadowFilter( 2, 45, 0X000000, 1, 2.0, 2.0, 1.0, 1);

            var filterArray:Array = new Array();
            filterArray.push(outline);
            _tf.filters = filterArray;
            _tf2.filters = [ds, outline];  


var sp:Sprite=new Sprite();
        sp.graphics.beginFill(Math.random()*0xFFFFFF);
        drawStar(sp.graphics, 0, 0, Math.random() * 100, Math.random() * 60, Math.random() * 360 - Math.random() * 360);
        drawStar(sp.graphics, 0, 0, Math.random() * 90, Math.random() * 50, Math.random() * 360 - Math.random() * 360);
        drawStar(sp.graphics, 0, 0, Math.random() * 80, Math.random() * 40, Math.random() * 360 - Math.random() * 360);
        sp.graphics.endFill();
        sp.y = stage.stageHeight / 2;
        sp.x = stage.stageWidth / 2;
        sp.filters = filterArray;
        init();
     Tweener.addTween(sp, { time:40, rotation: -2160, transition:"easeoutquart", delay:2});
     Tweener.addTween(sp, { time:30, _color:Math.random()*0xFFFFFF, transition:"easeoutquart", delay:2});
     Tweener.addTween(sp, { time:10, _color:null, transition:"easeoutquart", delay:22});
 
     addChildAt(sp, getChildIndex(_canvas)+1);
        
        var sp2:Sprite=new Sprite();            
        sp2.graphics.beginFill(0, 0);
        sp2.graphics.lineStyle(20, Math.random()*0xFFFFFF);
        sp2.graphics.drawCircle(0, 0, 45);
        drawStar(sp2.graphics, 0, 0, Math.random() * 81 + 70, Math.random() * 41 +60, Math.random() * 360 - Math.random() * 360);
        sp2.graphics.endFill();
        sp2.y = stage.stageHeight / 2;
        sp2.x = stage.stageWidth / 2;
        sp2.filters = [bf];
        sp2.alpha = 0.8;
        init(); 
        Tweener.addTween(sp2, { time:50, rotation: +2160, transition:"easeoutquart", delay:2});
        Tweener.addTween(sp2, { time:10, _color:Math.random()*0xFFFFFF, transition:"easeoutquart", delay:2});
        Tweener.addTween(sp2, { time:10, _color:Math.random()*0xFFFFFF, transition:"easeoutquart", delay:12});
        Tweener.addTween(sp2, { time:10, _color:Math.random()*0xFFFFFF, transition:"easeoutquart", delay:22});
        Tweener.addTween(sp2, { time:10, _color:null, transition:"easeoutquart", delay:32});
        addChildAt(sp2, getChildIndex(_canvas)+1);
      
        addChild(_tf2);  
        addChild(_tf); 

            _ta = new TextAnim(_tf);     
            _sequence = [
                {htmlText:"<font size=\"+20\"><b>TEXTANIM AS3</b></font>\nOPEN SOURCE LIBRARY", interval:50, effects:[effect1In, effect1Out], next:5},
                {htmlText:"FOR <font color=\"#d6156c\">DYNAMIC TEXT</font>\nANIMATION IN FLASH", interval:50, mode:"lastToFirst", effects:[effect2In, effect2Out], next:6},
                {htmlText:"IT'S EVENTS BASED AND TWEEN\n<font size=\"+20\">ENGINE <font color=\"#FCF8BC\">INDEPENDENT</font></font>", interval:30, mode:"random", effects:[effect2In, effect3Out], next:6},
                {htmlText:"<font size =\"22\">HAS NO READY-MADE ANIMATION</font>", interval:200, mode:"lastToFirst", split:"words", effects:[effect4In, effect4Out], next:5},
                {htmlText:"YOU CAN MAKE <font color=\"#d6156c\">WHATEVER</font>", interval:50, mode:"edgesToCenter", effects:[effect5In, effect5Out], next:6},
                {htmlText:"<font size=\"80\">TEXTANIM<br></font><font size=\"100\" color=\"#d6156c\"><b>AS3</b></font><br><font size=\"100\" color=\"#ffff00\">;)</font>", interval:100, mode:"centerToEdges", effects:[effect6In, effect5Out], next:22}
            ];
            
            init();      
            playNext();
    
            var myTimer:Timer = new Timer(2000,0);
            myTimer.addEventListener(TimerEvent.TIMER, timerListener);
            function timerListener (e:TimerEvent):void{
            trace("Timer is Triggered");
            dispatchEvent(new MouseEvent(MouseEvent.CLICK, true));
            _c = 1;
            }
            myTimer.start();
    
       })};
        
        public function playNext():void
        {
            _ta.mode = _sequence[_i].mode || "";
            _ta.split = _sequence[_i].split || "";
            _ta.effects = _sequence[_i].effects;
            _ta.interval = _sequence[_i].interval;
            _ta.htmlText = _sequence[_i].htmlText;
            _ta.blocksVisible = false;
            
            _ta.x = (stage.stageWidth/2) - (_ta.width/2);
            _ta.y = (stage.stageHeight/2) - (_ta.height/2);
            
            _ta.start();
            
            if ( _i == _sequence.length-1) {
            _i = 0;
             setTimeout(playNext, _sequence[_i].next * 1700);
              
            }
            
            else {
                setTimeout(playNext, _sequence[_i].next * 1200);
            _i ++;
            } 
 
        }

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;
                g.lineTo(px,py);
                
                angle += Math.PI/5;
                px = _x+Math.cos(angle)*outer;
                py = _y+Math.sin(angle)*outer;
                g.lineTo(px,py);
            }
        }


        public static function init():void 
        {
            ColorShortcuts.init();
            DisplayShortcuts.init();
            FilterShortcuts.init();
        }
        
                public function movePos():void {
 
        var sp3:Sprite=new Sprite();            
        sp3.graphics.beginFill(0, 0);
        sp3.graphics.lineStyle(Math.random()*8, Math.random()*0xFFFFFF);
        sp3.graphics.drawCircle(0, 0, 20);
        drawStar(sp3.graphics, 0, 0, Math.random() *50, Math.random() *50, Math.random() * 360 - Math.random() * 360);
        sp3.graphics.endFill();

        if ( _c == 1){

        sp3.y = stage.stageHeight / 2;
        sp3.x = stage.stageWidth / 2;
        _c = 0;
        }
        else {
            sp3.y = mouseY;
            sp3.x = mouseX;
        }

        
        var outline2:GlowFilter = new GlowFilter();
        outline2.blurX = outline2.blurY = 4;
        outline2.color = 0x000000;
        outline2.quality = BitmapFilterQuality.HIGH;
        outline2.strength = 4;
        
        var highest_depth: int = this.numChildren;
        sp3.filters = [outline2];
        this.addChildAt( sp3, highest_depth-1 );
                     
        Tweener.addTween(sp3, { x:stage.stageWidth / 2, rotation: +2160, time:7, transition:"easeOutElastic" } );
        Tweener.addTween(sp3, { y:stage.stageHeight / 2, time:6, transition:"easeOutElastic"});
        Tweener.addTween(sp3, { alpha:0, time:1.2, transition:"easeoutquart", delay:4 } );            
        Tweener.addTween(sp3, { scaleX: 5, scaleY: 5, time:4, transition:"easeoutBounce", delay:1});
        Tweener.addTween(_canvas, { _color:Math.random()*0xFFFFFF, time:4, transition:"easeoutBounce", delay:1});

        }
        
        public function onClick(event:MouseEvent):void {
            // add extra events if you like

       movePos();
        
        }
        
        public static function effect1In(b:TextAnimBlock):void
        {
            b.alpha = 0;
            b.rotation = 20;
            b.x = b.posX + 30;
            Tweener.addTween(b, {x:b.posX, rotation:0, time:.3, transition:"easeoutback"});
            Tweener.addTween(b, {alpha:1, time:.3, transition:"easeoutquart"});
        }
        
        public static function effect1Out(b:TextAnimBlock):void
        {
            Tweener.addTween(b, {_Blur_blurY:20, _Blur_blurX:20, time:1, transition:"easeinoutquart", delay:2});
            Tweener.addTween(b, {y:-(10 - Math.random()*20), rotation:Math.random()*30, time:1, transition:"easeinback", delay:2});
            Tweener.addTween(b, {alpha:0, time:.5, transition:"easeoutquart", delay:2.7});
        }
        
        public static function effect2In(b:TextAnimBlock):void
        {
            b.alpha = 0;
            b.scaleX = b.scaleY = 3;
            Tweener.addTween(b, {alpha:1, _scale:1, time:1,  transition:"easeoutquart"});
        }

        public static function effect2Out(b:TextAnimBlock):void
        {
            Tweener.addTween(b, {x:b.posX + 60, time:1, transition:"easeoutquart", delay:3});
            Tweener.addTween(b, {_scale:0, time:.5, transition:"easeoutquart", delay:3.2});
        }

        public static function effect3Out(b:TextAnimBlock):void
        {
            Tweener.addTween(b, {rotation:45 - Math.random() * 90, y:b.posY + (10 + Math.random()*30), time:1, transition:"easeinback", delay:3});
            Tweener.addTween(b, {alpha:0, time:.3, transition:"easeoutquart", delay:3.8});
        }
        
        public static function effect4In(b:TextAnimBlock):void
        {
            b.alpha = 0;
            b.x = b.posX - 100;
            Tweener.addTween(b, {alpha:1, x:b.posX, time:.5, transition:"easeoutback"});
        }
        
        public static function effect4Out(b:TextAnimBlock):void
        {
            Tweener.addTween(b, {_color:0xFFFFFF, time:.5, transition:"easeoutquart", delay:2.2});
            Tweener.addTween(b, {_scale:3, alpha:0, rotationY:90, time:1, transition:"easeinoutquint", delay:2.3});
        }
        
        public static function effect5In(b:TextAnimBlock):void
        {
            b.alpha = 0;
            b.y = b.posY - 100;
            Tweener.addTween(b, {alpha:1, y:b.posY, time:1, transition:"easeoutbounce"});
        }
        
        public static function effect5Out(b:TextAnimBlock):void
        {
            Tweener.addTween(b, {y:b.posY+100, alpha:0, time:.5, transition:"easeinback", delay:4.3});
        }
        
        public static function effect6In(b:TextAnimBlock):void
        {
            b.scaleX = b.scaleY = 0;
            Tweener.addTween(b, {_scale:1, time:6, transition:"easeoutbounce"});
        }
        
    }
}