-
Mic level changing frame?
Hi,
I dont know the first thing about Actionscript, so I dont know if this goes in Newbies or not because I'm not a newbie to Flash, just the programming aspect.
I originally found this online.
http://www.kirupa.com/developer/acti...microphone.htm
Basically what I'm looking for is this script:
m = Microphone.get();
attachAudio(m);
m.setUseEchoSuppression(false);
onEnterFrame = function () {
circle._xscale = circle._yscale = m.activityLevel+50;
};
EXCEPT that instead of scaling, I need the mic level to affect what frame is being shown.(Circle is a graphic symbol)
If miclevel is >10 and <30 then it should gotoandstop frame 2 of circle
If miclevel is >29 and <75 then it should gotoandstop frame 3 of circle
If miclevel is >74 then it should gotoandstop frame 4 of circle
otherwise circle should be on frame 1.
Can someone please plug this idea into this code? I would REALLY be grateful! I need this for a school project and don't know anyone who knows actionscript! I believe to someone who knows AS this should be fairly simple. Once I have the finished code, I can edit the frames to suit my puropse.
Please Help!
-
Are you looking for a solution in AS2 or AS3? Your example code is AS2.
-
-
In AS3, since you're in the AS3 forum, you could do something like:
Code:
var m:Microphone = Microphone.getMicrophone();
if (m != null){
m.setLoopBack(true);
m.setSilenceLevel(10, 10);
m.setUseEchoSuppression(true);
m.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
}
function activityHandler(event:ActivityEvent):void{
var micLevel:Number = m.activityLevel;
if ((micLevel > 10) && (micLevel < 30)){
circle.gotoAndStop(2);
}else if ((micLevel > 29) && (micLevel < 75)){
circle.gotoAndStop(3);
}else if (micLevel >74){
circle.gotoAndStop(4);
}else{
circle.gotoAndStop(1);
}
}
Your ranges overlap, but that doesn't look like it'll cause a problem. You may have to adjust m's silenceLevel and silenceTimeoutproperty to tweak how sensitive it is.
If the activity based functionality isn't working for you, you could just hook up a timer to poll the microphone activity level every so often.
-
its not working. I guess I'll post this is AS2 forum. See what they find.
Thanks for your help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|