Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 170889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:53:23+00:00 2026-05-11T12:53:23+00:00

I got this idea of expanding my trace() messages. Why trace() is all over

  • 0

I got this idea of expanding my trace() messages.

Why

trace() is all over my code, I want to turn them on/off by a simple command and maybe add some sort of priority functionality to the trace(), i.e.

myTrace.TraceMsg('loosehere',debugme, 0); myTrace.TraceMsg('winhere',debugme, 1);   

And when I run, only the one with the higher priority, ‘1’ in this case, shows.

There is a lot more functionality I would like to add as well, like logging messages to file and so on.

Problem

How do trace() work? -Is it possible to overload trace() somehow? -How would I implement the custom TraceMsg(what code here?) method?

Having some serious problems finding info on this subject on our favourite search engine, so any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:53:23+00:00Added an answer on May 11, 2026 at 12:53 pm

    trace() itself is a top-level function, not a class, so unfortunately we cannot extend it. That being said, we can utilize it in a simple class to do just what it does normally, only in this case the trace is based on conditions (i.e. Boolean – true|false, etc). First we create the Trace class, which we wouldn’t instantiate ourselves because we are utilizing a Factory design pattern through the class below, Tracer. Tracer is built around the singleton design pattern, yet utilizes the Factory pattern to instantiate instances of Trace, when the trace method of Tracer is called.

    //This class is handled by Tracer, which is right below it. //You WILL NOT instantiate these, nor hold references. package {     public class Trace     {         private function _value:*;         private function _trace:Boolean;          public function Trace(pValue:*, pTrace:Boolean):void         {           _value = pValue;           _trace = pTrace;         }         public function get value():*         {            return _value;         }         public function get trace():Boolean         {            return _trace;         }     } } //This is the important class and the only one you will work with. package {     /**      *Utilizes Singleton and Factory design patterns.      */     public class Tracer     {         private var _traceArray:Array;         private static var _instance:Tracer;          public function Tracer(pvt:PrivateClass = null):void         {             if(pvt == null)             {                 throw(new Error('You cannot instantiate this class directly, please use the static getInstance method.'));             }              _init();         }         public static function getInstance():Tracer         {             if(Tracer._instance == null)             {                 Tracer._instance = new Tracer(new PrivateClass());             }             return Tracer._instance;         }         public function trace(pValue:*, pTrace:Boolean):void         {            var trace:Trace = new Trace(pValue, pTrace);            if(trace.pTrace)            {                trace(pValue);            }         }         //Since we have the option for individual traces to be disabled         //I provide this to get access to any and all later.         public function traceAll():void         {             traceStr:String = _traceArray.toString();         }         public function get traceables():Array         {             return _traceArray;         }         //Here we provide a method to trace all, even if set to false in their constructor.         private function _init():void         {             _traceArray = new Array();         }     } } //Here we create a class that is OUTSIDE of the package. //It can only be accessed from within this class file.  We use this //to make sure this class isn't instantiated directly. class PrivateClass {     function PrivateClass():void     {         trace('can only be accessed from within this class file');     } }  //Now for use in doc class package {     import flash.display.Sprite;     import flash.events.Event;      //No need to import Tracer and Trace, they are also in the     //unnamed package.      public class DocumentClass extends Sprite     {         private var _tracer:Tracer;          public function DocumentClass():void         {             if(stage) _init();             else addEventListener(Event.ADDED_TO_STAGE, _init);         }         private function _init(e:Event = null):void         {             _tracer = Tracer.getInstance();             _tracer.trace(10*20, false);             _tracer.trace(10*20, 0); //SAME AS ABOVE             _tracer.trace('I love AS3', true); //traces             _tracer.traceAll(); //Would trace: 200, 200, I love AS3         }     } } 

    Keep in mind this is off the hip and very well could have a bug or two, but the idea is there; That is to say that this is not tested, it is merely to give you an idea of how you might implement this.

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 78k
  • Answers 78k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You must implement a explicit or implicit operator. class Imp_A… May 11, 2026 at 3:43 pm
  • added an answer If not for cross-site scripting restrictions this should work. Unfortunately… May 11, 2026 at 3:43 pm
  • added an answer It is not correct to use IP addresses (neither IPv4,… May 11, 2026 at 3:43 pm

Related Questions

I got this idea a long time ago when i saw an app do
Consider this... I am writing a class named Cache which will accept either a
I'm currently working on project with Haskell, and have found myself some trouble. I'm
I got this error when I am trying to run a simple PhP script

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.