25/01/2008

Daily Jam

Because I've not had time for a completly new Jam I've improved the code on yesterdays. Here it is, along with source.
[Adam, can you add a CSS class for script. Nice console font and in a box would be awesome. cheers.]

[REVISION 25th Jan 2008 12:58]
It appears that I haven't actually solved the problem, I've created another one. The movie clip that corrisponds to the source below can be found at http://www.the-root.co.uk/_GAD/jam/Microphone%20Test%2003.html

I'll be posting a propper soluction soon.


// This big goes in the main movie.
// Get Microphone
var mic:Microphone = Microphone.getMicrophone();
if (mic != null) {
mic.setUseEchoSuppression(true);
mic.setLoopBack(true);
}

// Microphone level update timer
var myTimer:Timer = new Timer(10, 0);
myTimer.addEventListener("timer", timerHandler);
myTimer.start();

function timerHandler(event:TimerEvent):void {
vUBar.scaleX = mic.activityLevel / 100;
}

function getVUBar():MovieClip {
if (vUBar != null) {
return vUBar;
}
else
{
return new MovieClip();
}
}


// This big goes inside the Sprite
var vUBar:MovieClip = parent.getVUBar();

var myTimer:Timer = new Timer(10, 0);
myTimer.addEventListener("timer", timerHandler);
myTimer.start();

function timerHandler(event:TimerEvent):void {
if ( this.hitTestObject(vUBar) ) {
if ( this.alpha < 0.7 ) {
this.alpha = this.alpha + 0.1;
}
} else {
if ( this.alpha > -1 ) {
this.alpha = this.alpha - 0.05;
}
}
}

No comments: