Hi All,
I started playing with this action scrip last year and really enjoy the problem solving side of it. This year I’m trying to work with exterior sensors and it has posed to be a challenge.
Right now I’m working with microphone objects and to start off slow I’m using the built in mic. My problem is that I looking to create a program that when I mouse down and hold, an object or mc on the stages will listen for the mic activity level and will continuously react to it. In this case I’m using just a ball and I trying to have it continually move up and down with the sound levels.
I have been trying to work using a loop for on enter frame, but have been unsuccessful. If anyone has suggestions about loops or any other way that I may be able to accomplish my task I would greatly appreciate the advice.
Here is what I have thus far:
//stage.addEventListener(Event.ENTER_FRAME, onEnter);
stage.addEventListener(MouseEvent.MOUSE_DOWN,moveWithSound);
function moveWithSound(event:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_DOWN,addBall2);
stage.addEventListener(MouseEvent.MOUSE_UP,dropBall2);
}
/*function onEnter(event:Event){
micNum=mic.activityLevel;
//ball2.y=micNum*3;
}*/
function addBall2(event:MouseEvent):void {
var ball2:MovieClip = new Ball2;
addChild(ball2);
ball2.x = mouseX;
ball2.y = mic.activityLevel * 3;
//ball2.y = gotoAndStop(mic.activityLevel * 3);
//ball2.y=micNum*3;
}
Any suggestions may help.