InfoLabel 吹出しテキスト
♥0 |
Line 98 |
Modified 2014-06-03 13:04:04 |
MIT License
archived:2017-03-20 03:19:51
ActionScript3 source code
/**
* Copyright tepe ( http://wonderfl.net/user/tepe )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/3nuJ
*/
package {
import flash.display.*;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var info:InfoLabel = new InfoLabel()
addChild(info);
info.x = 100;
info.y = 100;
info.text = "!";
var info2:InfoLabel = new InfoLabel()
addChild(info2);
info2.x = 300;
info2.y = 150;
info2.text = "テスト";
}
}
}
import flash.filters.DropShadowFilter;
//////////////////////////////////////////////////
// 吹出し
//////////////////////////////////////////////////
import caurina.transitions.Tweener;
import flash.text.*;
import flash.display.*;
import flash.utils.*;
class InfoLabel extends Sprite{
private var _text:String ="";
public function InfoLabel(str:String=""){
_text = str;
this.mouseEnabled = this.mouseChildren = false;
draw();
}
public function set text(str:String):void{
_text = str;
draw();
}
public function pop(t:Number=1,f:Function=null):void{
this.scaleX =0;
Tweener.addTween(this,{
time:t,
scaleX:1,
transition: "easeOutQuint",
onComplete:f
});
}
public function fadeIn(t:Number=2,f:Function=null):void{
this.alpha = 0;
Tweener.addTween(this,{
time:t,
alpha: 1,
transition: "easeOutQuint",
onComplete:f
});
}
public function fadeOut(t:Number=2,f:Function=null):void{
this.alpha=1;
Tweener.addTween(this,{
time:t,
alpha: 0,
transition: "easeOutQuint",
onComplete:f
});
}
private function createBase(w:Number,h:Number):Sprite{
var c:uint = 0xdddddd;
var x1:Number= w/2;
var y1:Number= h+15;
var x2:Number= x1-5;
var x3:Number= x1+5;
var y2:Number= h+5;
var s:Sprite = new Sprite();
with(s.graphics){
clear();
beginFill(c);
drawRoundRect(-10,-5,w+20,h+10,10,10);
endFill();
beginFill(c);
moveTo(x2,y2);
lineTo(x3,y2)
lineTo(x1,y1);
lineTo(x2,y2);
endFill();
}
return s;
}
//描画
private function draw():void{
while(0<this.numChildren)this.removeChildAt(0);
var tf:TextField = new TextField();
tf = new TextField();
tf.selectable = false;
tf.text = _text;
tf.width = tf.textWidth+5;
tf.height = tf.textHeight+5;
var s:Sprite = createBase(tf.width,tf.height);//new Sprite();
/*var s2:Sprite = createBase(tf.width,tf.height);
s2.alpha = 0.2;
s2.filters = [new DropShadowFilter(5,5,0x000000,1,1,3,3)];
s2.x = -tf.width/2;
s2.y = -tf.height/2;
this.addChild(s2);
*/
s.addChild(tf);
s.x = -tf.width/2;
s.y = -tf.height/2;
s.alpha = 0.9;
this.addChild(s);
}
}