// // @auteur: YopSolo // @mail: mail@yopsolo.fr // @site: http://www.yopsolo.fr // package fr.yopsolo.utils{ import flash.display.Sprite; import flash.text.TextFormat; import flash.text.TextField; import flash.events.MouseEvent; import flash.filters.DropShadowFilter; public class Console extends Sprite { private var VERSION:String = "v 1.0"; private var tf:TextField; public function Console(couleur_text:uint = 0x0 , couleur_fond:uint = 0xCCCCCC, largeur:uint = 300, hauteur:uint = 200 ) { this.filters = [ new DropShadowFilter(3, 45, 0x0, 33, 3, 3, 2, 2, false, false, false) ]; this.x = 10; this.y = 20; // création du sprite de drag var bg:Sprite = new Sprite(); bg.graphics.beginFill( couleur_fond ); bg.graphics.drawRect( 0, 0, 15, 15); bg.graphics.endFill(); bg.x = largeur -15; bg.y = -16; bg.buttonMode = true; bg.addEventListener( MouseEvent.MOUSE_DOWN, dragMe ); bg.addEventListener( MouseEvent.MOUSE_UP, stopDragMe ); this.addChild( bg ); // ============================ // création du textField tf = new TextField(); tf.width = largeur; tf.height = hauteur; tf.wordWrap = true; tf.background = true; tf.backgroundColor = couleur_fond; // création du format var fmt:TextFormat = new TextFormat(); fmt.font = "_typewriter"; fmt.color = couleur_text; fmt.size = 12; tf.defaultTextFormat = fmt ; this.addChild( tf ); // message d'acceuil this.addMessage("~ DEBUG CONSOLE ~ "+this.VERSION); this.addMessage(); } public function addMessage( message:String = '' ):void { tf.appendText( message+"\n" ); tf.scrollV = tf.maxScrollV; } private function dragMe(e:MouseEvent):void { this.startDrag(); } private function stopDragMe(e:MouseEvent):void { this.stopDrag(); } } }