1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
class CTextKiBouge {
static var num:Number=new Number(0);
private var theText:String;//private : on utilise l'encapsulation
private var target:MovieClip;//private : on utilise l'encapsulation
public function CTextKiBouge (_target:MovieClip, _text:String){
this.theText=_text;
/*
On crée un clip qui contiendra le champs de texte.
*/
this.target = _target.createEmptyMovieClip("container"+num, _target.getNextHighestDepth());
var level:Number = this.target.getNextHighestDepth();//pour la maintenabilité
this.target.createTextField("labbel",level, 0, 0, 150, 20);
this.target.labbel.border=true;//le texte est encadré
this.target.labbel.text=_text;
this.dessineContourDuClipDeTextKiBouge();//facultatif
//on incremente num afin de donner un nom unique au clip crée par CTextKiBouge
num++;
}
public function set changeText(_text:String){
this.target.labbel.text=_text;
}
public function moveText(x:Number,y:Number){
this.target._x=x;
this.target._y=y;
}
private function dessineContourDuClipDeTextKiBouge()
{
this.target.lineStyle(5, 0xFF00FF, 100);
this.target.moveTo(0, 0);
this.target.lineTo(200, 0);
this.target.lineTo(200, 200);
this.target.lineTo(0, 200);
}
} |
Partager