Press "Enter" to skip to content

Primal Screen’s Mic AS3 Output class

Today I committed the first version of my Mic AS3 class to Primal Screen‘s Github repository.

The purpose of this class is to organize your Output window into something much more usable. I wrote it in out typical relaxed Primal Screen style— very human readable, very easy to figure out what function does what.

First, import the class:

import com.primalscreen.utils.Mic;

Then say something into the Mic:

Mic.say("This is a test", this);

And you should see this in your output window:

myClass says:  This is a test

The Mic class uses that reference to “this” to grab the name of the class that is “talking” to it, so you can see where the message is coming from, then it adds spaces where needed to line everything up. When you say things from a few different classes, you see the power in this:

       myClass says:  This is a test
  SoundManager says:  Playing sound "1.mp3"
       myModel says:  The button was pushed
  myController says:  Message recieved!
        myView says:  All your base are belong to us!

That’s a lot of “says: ” isn’t it? Well that’s because we’re being calm, and well mannered. We’re saying things that ought to be said. Important things should be yelled!

Mic.yell("This must be important!", this);

When the app starts to get big, with lots of traces, and you just want the big picture, turn off the normal speech, so you just hear the important stuff that you yelled (or screamed, we’ll get to that):


Some things we don’t care about much, but on the off chance that we’re tearing our hair out in über-debug mode, and want every last bit of data, we should still whisper it:

Mic.whisper("Nobody cares about what I'm saying right now", this);

Or if it’s super-duper important, we want to SCREAM it, and we can:

Mic.scream("Something crazy is happening!", this);

In the hierarchy it goes whisper, say, yell, scream, and when you ignore a level, you ignore the ones below it too. What about ignoring a class:

// this is a reference to the SoundManager class object
// this works too, and we don't need an actual object reference
Mic.silence(this); // an alias for ignore

Mic.unsilence(this); // an alias for unignore

What about the opposite, when we want to focus on the output of one particular class?

Mic.spotlight(SoundManager); // class ref
Mic.spotlight("SoundManager"); // class name as string
Mic.focus(this); // an alias for spotlight

Mic.unfocus(this); // an alias for unspotlight

And I didn’t cover it above, but here are the other ignore functions:

Mic.ignoreSays(); // a grammatically incorrect alias
Mic.ignoreAll(); // alias for ignore screams

Hope you like it!

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: