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

BlaBla Bubble

forked from: シュールなAS3.0 #4 カーソルにコメントさせてみた
/**
 * Copyright Glav ( http://wonderfl.net/user/Glav )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bY6S
 */

package {
    import flash.display.Sprite;
    
    [SWF(width = 465, height = 465, frameRate = 60, backgroundColor = 0xcccccc)]
    public class Phylactere extends Sprite {
        
        private var balloon:Balloon;
        
        public function Phylactere() {
            balloon = new Balloon();
            addChild(balloon);
            
            balloon.doComment("Lions meet the needs of local communities", 30, 110);
        }
    }
}



import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.media.Sound;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.display.Sprite;
import flash.text.TextFormat;
import flash.text.TextField;
import org.libspark.betweenas3.*;
import org.libspark.betweenas3.tweens.ITween;
import org.libspark.betweenas3.events.*;
import org.libspark.betweenas3.easing.*;

class Balloon extends Sprite
{
    private const epaisseur:uint = 3;
    
    private var textfield:TextField;
    private var hauteur:uint;    // 全ての基準的な値として使用
    private var timer:Timer;
    
    private var totalText:String;
    private var currentLen:uint;
    
    private var sound:Sound = new Sound(new URLRequest("http://www.sarcueil.fr/wonderfl/blabla.mp3"));
    private var channel:SoundChannel = new SoundChannel();
    
    //channel = snd.play(0, 0, new SoundTransform(1, (x / stage.stageWidth - 0.5) * 2));
    
    public function Balloon ():void {
        textfield = new TextField()
        textfield.autoSize = "left";    // ここにもってこないとなぜか、文字が巨大化する
        this.alpha = 0;
        addChild(textfield);
        textfield.text = "AbcM1";
        hauteur = textfield.height;
        
        textfield.defaultTextFormat = new TextFormat("", hauteur);
        textfield.x = hauteur*0.7;
        textfield.y = -hauteur * 0.6;
    }
    
    public function doComment(txt:String, _x:Number, _y:Number):void {
        this.alpha = 0;
        this.x = _x; this.y = _y;
        totalText = txt;
        currentLen = 0;
        textfield.text = totalText;
        
        BetweenAS3.to(this, { alpha:1 }, 0.2).play();
        
        // 四角形のパーツ
        with (this.graphics) {
            clear();

            beginFill(0xFFFFFF);
            lineStyle(epaisseur * 0.5, 0x0);
            drawRect(+hauteur * 0.25, -hauteur, textfield.width + hauteur*0.8, hauteur * 2 + epaisseur/4);
            endFill();
            lineStyle();
            
            // 三角形の吹きだしっぽいやつ
            beginFill(0xffffff);
            moveTo(+hauteur, +hauteur);
            lineTo(+hauteur * 2, +hauteur);
            lineStyle(epaisseur * 0.5, 0x0);
            lineTo(+hauteur * 1.5, +hauteur * 1.75);
            endFill();
        }
        
        textfield.text = "";
        
        channel = sound.play(0, int.MAX_VALUE);
        
        timer = new Timer(50, totalText.length);
        timer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent):void {
            textfield.text = totalText.substring(0, ++currentLen);
            if(currentLen == totalText.length) {
                BetweenAS3.delay(BetweenAS3.to(parent, { alpha:0 }, 0.2), 3).play();
                channel.stop();
            }
        });
        timer.start();
    }
    

}