Tag Archives: primalscreen

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):

Mic.ignoreSpeech();

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:

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

Mic.unignore(this); 
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(this);
Mic.spotlight(SoundManager); // class ref
Mic.spotlight("SoundManager"); // class name as string
Mic.focus(this); // an alias for spotlight

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

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

Mic.ignoreWhispers();
Mic.ignoreSpeech();
Mic.ignoreSays(); // a grammatically incorrect alias
Mic.ignoreYells();
Mic.ignoreScreams();
Mic.ignoreAll(); // alias for ignore screams

Hope you like it!

Actionscript SoundManager Class Updated

There have been lots of changes to my SoundManager class since it’s original release, so I want to run through them here quickly.

First of all, it now lives on Primal Screen‘s Github repository. I’ll always keep the latest version there.

Second, there are lots of feature changes. Versions later than b0.7 are not compatible with earlier versions, but updating your code would be totally worth it, as a lot has changed, and for the better. Some of the new features:

  • Options objects – No more function calls with 5 or 10 arguments, now your options are in an anonymous object, jQuery style
  • Verbose modes – Set how wordy SoundManager gets in your output window
  • Priorities – Instead of “interrupts,” now a numerical priority decides whether a sound plays or not if it’s on the same channel as another sound.
  • Play, Pause, Resume, and Stop – Complete control over playback, by ID, channel, caller, or all
  • The FromThis functions – playSound() now takes a reference to this as it’s second argument, and you can use that later to control playback on all sounds from that calling class. Useful for cleaning up classes before destroying.
  • Preloading of files
  • Better resource management.
  • Moved to com.primalscreen.utils classpath. I know, pain-in-the-ass, but I had to.

Let me know if you’re using my SoundManager, and how it works for you.