00:00
00:00
Newgrounds Background Image Theme

bugblast just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS : Microphone

7,185 Views | 46 Replies
New Topic Respond to this Topic

AS : Microphone 2006-07-26 11:56:41


AS:Main - Now comes with No0b repelant

What you'll learn, hopefully
In this tutorial i'll explain about the 'Microphone' Object introduced in Flash MX2004. I'll also show some neat effects
you can use in one of your flashes as mabye a preloader, or with a little more knowledge, a full blown game.

Is it hard?
The mike object is very similar to the Camera Object
in flash. It uses some very similar properties. So if you know about the Camera object, how it works,how to apply it, then this should be a pretty simple tutorial.

How to use it!

Now onto the actual tutorial. If you ever get stuck, or are shouting 'wtf' and hitting your computer, just click on one of the links at the bottom and they should give a little

more info.
Alot of this code is taken from macromedia live docs, so if you get stuck, they are probably a good place to look.

Getting the mike!

To do anything with the mike in flash, you have to actuall find the appropriate mike and apply it to an object to do that
paste these actions in a frame in you flash. I'll explain afterwords:-


this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);

Now for the explaination.
1. The first line creates and empty movie clip on the timline, and calls it "sound_mc".
2. Then a new variable called active_mic is created. It is declared a Microphone object.
3. On the same line 'Microphone.get();' is used. This applies the default mike to the Mircophone Object.
4. The last line actually makes out Object usable on the stage. It applies our Object (active_mic) to our MC.

Now, try testing you movie. If you speak into the mike you should be able to hear your voice amplified coming from
your speakers.

Making it clearer!

When you tested the previous example the sound may have appeared muffled, or abit fuzzy. In this part i'll tell you how to
make the sound alot clearer and easier on the ear.

Put this code after the code you just pasted on the timline:-


active_mic.setRate(22);
active_mic.setUseEchoSuppression(true);

Explanation:-
1. The top line sets the Microphone amount of Khz per second, The higher the number(uaually) the better the quality.
2. The second line tells the miek to use echo suppresion. This reduces the amount of feedback from the speakers, making the sound clearer.

Now if you test your movie. The sound should be clearer. If you don't notice any difference, fiddle around with the mike settings by right clicking on your preview movie,
clicking settings, then going onto the mike tab.

How to see sound!
In this final part of the tutorial i'll show you lot how to make a shape's properties change by the level of activity the mike is detecting. You could make it rotate, go smaller,
get bigger, change colour, anything you want. I'm going to work on scale, it is one of the simpler open, so most people should understand it.
It basically makes the shape expand, retract depending on the level of sound detected. The more sound, the bigger the shape.

Just paste this code under your current code:-


var amount:Number =50;
onEnterFrame = function () {
shape._xscale = shape._yscale = active_mic.activityLevel+amount;
};

And then make a Movie Clip on the stage, it can be any size, shape, whatever you want. Give it the instance name 'shape'.

Now if you test the movie when you speak into the mike the shape will expand and retract. To get different effects, just shange the variable 'amount'
to a different number. You can also try using different properties to change the effect, for example:-


var amount:Number =50;
onEnterFrame = function () {
shape._xscale = shape._yscale=active_mic.activityLevel+amo
unt;
shape._rotation = active_mic.activityLevel+amount;
shape._x = active_mic.activityLevel+amount;
shape._y = active_mic.activityLevel+amount;
};

That code will make the shape move around the stage, rotate, expand and retract, all depending on the level of microphone ativity.

That conculdes the long tutorial on the flash microphone object. I hope you understood most of it, don't just copy and paste the code though, read the explanations,
They should explain most of the code. Below is an examples of the final product! If you have any questions, just post them below.

EXAMPLE
Fully Done Project!

HELPFUL LINKS
Marcomedia

Live Doc(MX 2004)
Kirupa's Tutorial
AS : Video - My other AS

1004th Post :)

BBS Signature

Response to AS : Microphone 2006-07-26 12:14:47


At 7/26/06 12:05 PM, EscapeFromReality wrote: That is great, i am defiently going to have a go at this, i bet it would be possible to use this to make a game, like a platformer, using commands, like blows to move him.

Great tutorial.

That's be cool. I don't believe that flash can understand vocals (e.g. hello), but it'd be quite cool if you could blow a balloon using the mike.
I might give that a shot aswell, just as an experiment.

Isn't there a DS game like that?

BBS Signature

Response to AS : Microphone 2006-07-26 12:29:42


At 7/26/06 12:19 PM, EscapeFromReality wrote: A mini game on Mariokart, you drive around blowing uo balloons.

I thought so. Cheers.

Anyone else have any comments?

BBS Signature

Response to AS : Microphone 2006-07-26 12:47:10


Awesome tutorial, great for beginners.

Response to AS : Microphone 2006-07-26 14:14:05


At 7/26/06 12:47 PM, JamsCo wrote: Awesome tutorial, great for beginners.

Cheers, it's not complicated AS, it'll probably go in the Basic Section of AS:Main.

Hopefully:)

BBS Signature

Response to AS : Microphone 2006-07-26 15:04:06


Nice, but you should've added all properties to the object. index for example.
Mic.index equals the mic the user is using.


BBS Signature

Response to AS : Microphone 2006-07-26 15:08:31


Damn, something must be wrong. My microphone works and it's plugged in correctly, but I don't get any sound from the microphone in Flash.

Response to AS : Microphone 2006-07-26 15:11:49


At 7/26/06 03:04 PM, ViktorHesselbom wrote: Nice, but you should've added all properties to the object. index for example.
Mic.index equals the mic the user is using.

I decided to leave them out because they are not an essential bit in using the mike. There is a link at the bottom though for the camera object, so poeple can look that up there.

To the person above, i'm not sure what is wrong. Try messing around with your mike settings in the voluem controls.


BBS Signature

Response to AS : Microphone 2006-07-26 15:24:12


It's tuned properly, it works on Skype and when I go into the volume settings in the tool bar, un-mute the microphone and I can hear myself. When I go into the Flash player I go to settings I go to the microphone settings and it's like it doesn't recognize it.

Response to AS : Microphone 2006-07-26 15:30:57


At 7/26/06 03:24 PM, TechnoTrepidity wrote: It's tuned properly, it works on Skype and when I go into the volume settings in the tool bar, un-mute the microphone and I can hear myself. When I go into the Flash player I go to settings I go to the microphone settings and it's like it doesn't recognize it.

Weird, i'm afraid its nt to do with my tutorial. Try the example and tell me if it works.


BBS Signature

Response to AS : Microphone 2006-07-26 16:31:13


Thanks for putting this up, man.


D:

BBS Signature

Response to AS : Microphone 2006-07-27 07:40:54


At 7/26/06 04:31 PM, CubeInABox wrote: Thanks for putting this up, man.

No problem. I'm glad it helped.

Any more comments?

BBS Signature

Response to AS : Microphone 2006-07-27 08:07:25


This is awesome. Lol, do I hear karaoke Flash games?

Response to AS : Microphone 2006-07-27 08:14:42


Nice tutorial, goes nicely along side AS: Webcam or whatever its called. I have yet to try it out but it looks like it should work :p

Response to AS : Microphone 2006-07-27 08:39:03


Thanks so much! i am making a game where you use the mike to kill the bad guys ( iam almost done with lvl one

Response to AS : Microphone 2006-07-27 09:16:12


At 7/27/06 08:39 AM, loneronin1 wrote: Thanks so much! i am making a game where you use the mike to kill the bad guys ( iam almost done with lvl one

Sounds good. I'm glad you all like the tutorial. P.M me when you've done that game, it'd be intresting to see.

Anyone else?

BBS Signature

Response to AS : Microphone 2006-07-27 09:37:55


At 7/27/06 09:16 AM, Depredation wrote:
At 7/27/06 08:39 AM, loneronin1 wrote: Thanks so much! i am making a game where you use the mike to kill the bad guys ( iam almost done with lvl one
Sounds good. I'm glad you all like the tutorial. P.M me when you've done that game, it'd be intresting to see.

ok i will

Response to AS : Microphone 2006-07-27 22:45:11


At 7/27/06 09:16 AM, Depredation wrote:
At 7/27/06 08:39 AM, loneronin1 wrote: Thanks so much! i am making a game where you use the mike to kill the bad guys ( iam almost done with lvl one
Sounds good. I'm glad you all like the tutorial. P.M me when you've done that game, it'd be intresting to see.

Anyone else?

you get a cool point!

AS : Microphone

Response to AS : Microphone 2006-07-28 00:35:21


At 7/27/06 10:45 PM, loneronin1 wrote: you get a cool point!

He only gets .5 of a cool point!
This is incredibly basic... Any fool who knows how to use the flash help can learn this..

But none the less no one has done this yet. So meh.

Response to AS : Microphone 2006-07-28 01:22:04


but he gets another .5 of a cool point for giving me an idea for a game

Response to AS : Microphone 2006-07-28 01:26:04


wow when you type you spare no expense do you? :D

Response to AS : Microphone 2006-07-28 01:44:08


At 7/28/06 01:26 AM, royevans wrote: wow when you type you spare no expense do you? :D

who?

Response to AS : Microphone 2006-07-28 08:04:22


At 7/28/06 12:35 AM, shazwoogle wrote: He only gets .5 of a cool point!
This is incredibly basic... Any fool who knows how to use the flash help can learn this..

But none the less no one has done this yet. So meh.

He's right, its not very advanced. I like doing these type of tutorials though, because i never muck up. I thought about doing another one called 'Trignometry for Dummies' but i want to learn more about it before i do :)

Thanks for half a cool point i now have a total of, 0.5 :'(

BBS Signature

Response to AS : Microphone 2006-07-28 08:06:45


please stop bumping this thread. if people need help with this they'll ask for it.


========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

Response to AS : Microphone 2006-07-28 08:21:01


Pretty helpful, thanks. Be cool to see some microphone games.


BBS Signature

Response to AS : Microphone 2006-08-03 15:43:45


i just wondered if you use the same kind of actionscript to make an object move in time to music?

Response to AS : Microphone 2006-08-04 12:08:10


At 8/3/06 03:43 PM, technofreak1 wrote: i just wondered if you use the same kind of actionscript to make an object move in time to music?

i don't think so, i tried it, and it didn't work. But i may have mucked it up somwhere, try it, and a few otehr things then if it fails PM the guy who made 'streamline' on the front page, or make a topic for it on the flash forum.
:)


BBS Signature

Response to AS : Microphone 2006-08-04 14:20:18


Did you know that if you stick your microphone in your butt it sounds like shit?

LOLOLOLOLOLOLOLOLOLOLOLOLOLOLOL


wtfbbqhax

Response to AS : Microphone 2006-08-04 15:49:16


At 8/4/06 02:20 PM, fwe wrote: Did you know that if you stick your microphone in your butt it sounds like shit?

LOLOLOLOLOLOLOLOLOLOLOLOLOLOLOL

Yup, been there done that, XD. jk. Anyway, please don't spam my amazing AS.

Its too precious :(

BBS Signature

Response to AS : Microphone 2006-10-28 19:21:51


This is great, i'm working on a game where you should scream so the glass breaks, and you have to scream louder for each level.