topical media & game development

talk show tell print

#graphic-player-10-cube-be-nascom-flex-component-FlexSimpleTraceBox.ax

#graphic-player-10-cube-be-nascom-flex-component-FlexSimpleTraceBox.ax [swf] [flash] flex


  package be.nascom.flex.component{
          
          import flash.events.Event;
          
          import mx.controls.TextArea;
          import mx.events.FlexEvent;
                  
          public class @ax-graphic-player-10-cube-be-nascom-flex-component-FlexSimpleTraceBox extends TextArea{
                  
                  public static const ALERT_EARLY_TRACES:Boolean=false;
                  
                  private static var _pre_text_area_traces:String="";
                  
                  public static var text_area:TextArea=null;
                  
                  public static function setTextArea(ta:TextArea):void{
                          text_area=ta;
                          text_area.text="::Init @ax-graphic-player-10-cube-be-nascom-flex-component-FlexSimpleTraceBox TextArea::\n";
                          text_area.text+="**Pre TextArea Traces:\n"+_pre_text_area_traces;
                          text_area.text+="**Post TextArea Traces:\n";
                          _pre_text_area_traces=null;
                  }
                  
                  //FIND A WAY TO DYNAMICALLY EXTRACT CALLING CLASS AND METHOD NAMES?! POSSIBLE?!
                  public static function trace(...args):void{
  
                          var stri:String="";
                          for each(var arg:Object in args){
                                  if(arg is String){
                                          stri+=arg+"\n";
                                  }else if(arg.toString!=null){
                                          stri+=arg.toString()+"\n";;
                                  }
                          }
                          if(text_area==null){
                                  _pre_text_area_traces+=stri;
                                  return;
                          }
                          text_area.text+=stri;
                          text_area.validateNow();
                          text_area.verticalScrollPosition=text_area.maxVerticalScrollPosition;
                  }
                  
                  public static function clear():void{
                          if(text_area!=null){
                                  text_area.text="";
                          }
                  }                        
                  
  
                  public function @ax-graphic-player-10-cube-be-nascom-flex-component-FlexSimpleTraceBox(){
                          super();
                          addEventListener(mx.events.FlexEvent.CREATION_COMPLETE,init);
                  }
                  
                  private function init(e:Event=null):void{
                          @ax-graphic-player-10-cube-be-nascom-flex-component-FlexSimpleTraceBox.setTextArea(this);
                  }
                  
          }
  }


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.