forked from: Enjoy It!

by gahaku500 forked from Enjoy It! (diff: 14)
Heya, Love!
♥0 | Line 103 | Modified 2010-11-19 12:41:34 | MIT License
play

ActionScript3 source code

/**
 * Copyright gahaku500 ( http://wonderfl.net/user/gahaku500 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ZS1a
 */

// forked from telcanty's Enjoy It!
package{
    /*
    
        Heya, Love!

    */
    
    import flash.display.Sprite;
    
    import flash.events.Event;
    
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.text.TextFieldAutoSize;
    
    public class Main extends Sprite
    {
        
        public var halfWidth:Number = stage.stageWidth / 8;
        
        public var lovingOptions:Array = new Array(
                "Cuddle Bunny",
                "Silly Girl",
                "Darling",
                "My Delight",
                "Delicatessen",
                "Sexy Moma",
                "Beautiful",
                "Luscious",
                "Ms. Cash",
                "Sweetheart",
                "Love"
                );
        public var lovingOptionNum:int = Math.random()*lovingOptions.length - 1;
        public var lovingOption:String = lovingOptions[lovingOptionNum];
        
        public var maxScale:Number = 5.2;
        public var minScale:Number = .2;
        public var textOffset:Number = 50;

        public var heartFormat:TextFormat = new TextFormat();
        public var heartText:TextField = new TextField();
        public var happyFormat:TextFormat = new TextFormat();
        public var happyText:TextField = new TextField();
        public var loveFormat:TextFormat = new TextFormat();
        public var loveText:TextField = new TextField();
        public var bgrdColor:Number = 0xFFFFFF * Math.random();
        public var bgrd:Sprite = new Sprite();
        
        public var scaleIncrement:Number = .2;
        public var majorUpdateFrame:Number = 500;    // frameRate on 30
        public var currentUpdateFrame:Number = 500;
    
        public function Main():void
        {
            _init();
        }
        
        public function Update(e:Event = null):void
        {
            // DO MAJOR UPDATE IF NECESSARY
                if(currentUpdateFrame >= majorUpdateFrame)
                {
                    // CHANGE SAYING
                        lovingOptionNum = Math.random()*lovingOptions.length - 1;
                        lovingOption = lovingOptions[lovingOptionNum];
                        loveText.text = String(lovingOption).toUpperCase();
                    // RESET CURRENT UPDATE
                        currentUpdateFrame = 0;
                }else{
                    currentUpdateFrame++;
                }
                
            // DRAW BACKGROUND
                bgrd.graphics.beginFill(0xFFFFFF * Math.random());
                bgrd.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
                bgrd.graphics.endFill();
                
            // RANDOMIZE COLOR
                heartFormat.color = 0xFFFFFF*Math.random();
                heartText.setTextFormat(heartFormat);
            
            // ITERATE SIZING
                heartText.scaleX = heartText.scaleY += scaleIncrement;
                if((heartText.scaleX >= maxScale)||(heartText.scaleX <= minScale))
                {
                    scaleIncrement *= -1;
                }
            
            // REPOSITION ITEMS
                heartText.x = halfWidth - heartText.textWidth / 8 * heartText.scaleX;
                heartText.y = stage.stageHeight / 2 - heartText.textHeight / 2 * heartText.scaleY + textOffset - textOffset / 8;
                happyText.x = halfWidth - happyText.textWidth / 2;
                happyText.y = heartText.y - textOffset;
                loveText.x = halfWidth - loveText.textWidth / 2;
                loveText.y = heartText.y + heartText.textHeight * heartText.scaleY - textOffset;
        }
        
        public function PositionObjects():void
        {
            
        }
        
        private function _init():void
        {
            // HEART TEXT
                heartFormat.size = 700;
                heartFormat.color = 0x000000;
        
                heartText.defaultTextFormat = heartFormat;
                heartText.autoSize = TextFieldAutoSize.LEFT;
                heartText.text = "あっぷる";
                heartText.selectable = false;
                heartText.scaleX = heartText.scaleY = minScale;

        
            // HAPPY TEXT
                happyFormat.size = 500;
                happyFormat.color = 0xFFFFFF;
        
                happyText.defaultTextFormat = happyFormat;
                happyText.autoSize = TextFieldAutoSize.LEFT;
                happyText.text = String("うんこ").toUpperCase();
                happyText.selectable = false;

            // HAPPY LOVE
                loveFormat.size = 8000;
                loveFormat.color = 0xFFFFFF;
                loveText.defaultTextFormat = loveFormat;
                loveText.autoSize = TextFieldAutoSize.LEFT;
                loveText.text = String(lovingOption).toUpperCase();
                loveText.selectable = false;
                
            // STAGE ADDITIONS
                addChild(bgrd);
                addChild(happyText);
                addChild(heartText);
                addChild(loveText);
            
            // START UPDATE
                addEventListener(Event.ENTER_FRAME, Update);
                Update();
        }
    }
}