forked from: ほにほに!ふわっ!ふわっ!

by undo
♥0 | Line 51 | Modified 2011-09-27 16:43:30 | MIT License
play

ActionScript3 source code

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

// forked from kuroclef's ほにほに!ふわっ!ふわっ!
package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import org.libspark.betweenas3.BetweenAS3;
    import org.libspark.betweenas3.tweens.ITween;
    
    [SWF(backgroundColor = 0xffaaff, frameRate = 60)]
    public class Main extends Sprite {
        public function Main() {
            var count:int = 0;
            
            var text:TextField;
            text   = TextUtil.createText('_sans', 32, 0x0066FF, "新・気功砲!");
            text.x = (stage.stageWidth - text.textWidth) / 2;
            text.y = (stage.stageHeight - text.textHeight) / 2;
            addChild(text);
            
            var texts:Array = [];
            for (var i:int = 0; i < 5; i++) {
                var subSprite:Sprite = new Sprite();
                subSprite.alpha = 0;
                addChild(subSprite);
                texts.push(subSprite);
                
                var subText:TextField;
                subText   = TextUtil.createText('_sans', 120, 0x0066FF, "はぁっ!");
                subText.x =  - subText.textWidth / 2;
                subText.y =  - subText.textHeight / 2;
                subSprite.addChild(subText);
            }
            
            stage.addEventListener(MouseEvent.MOUSE_DOWN, function(event:MouseEvent):void {
                texts[count].x = mouseX;
                texts[count].y = mouseY;
                BetweenAS3.tween(texts[count], { alpha:0, scaleX:1, scaleY:1 }, { alpha:1, scaleX:0, scaleY:0 }, 0.4).play();
                count = count == texts.length - 1 ? 0 : ++count;
            });
        }
    }
}

import flash.text.TextField;
import flash.text.TextFormat;

class TextUtil {
    public static function createText(font:String, size:int, color:int, text:String):TextField {
        var textField:TextField = new TextField();
        textField.autoSize      = "left";
        //textField.embedFonts    = Boolean(font);
        textField.selectable    = false;
        textField.text          = text;
        textField.wordWrap      = false;
        
        var textFormat:TextFormat   = new TextFormat(font, size, color);
        textField.defaultTextFormat = textFormat;
        textField.setTextFormat(textFormat);
        
        return textField;
    }
}

Forked