is hittest CRAZY?
im having some problems with hittest.
im making a prizewheel that spins that is at early stages of development.
the idea is, the louder the mic input is the more the wheel spins.
the problem im currently having is the hittest. i need to see my arrow stands and the end of the spin, and it kinds like hittest is acting strange on me. am i using it correctly? does it not like being triggered on a function?
it always display the last number it passed over not touching…
idea can be seen at http://www.austereo.com.au/clients/prizewheel_temp/wheel.swf
the code used is…
#include "mc_tween2.as"
createEmptyMovieClip("micAudio",3);
micAudio.attachAudio(Microphone.get());
inputMic = Microphone.get();
inputMic.setUseEchoSuppression(1);
inputMic.setRate(44);
inputMic.setSilenceLevel(15);
inputMic.setGain(90);
inputSound = new Sound(micAudio);
inputSound.setVolume(0);
//onEnterFrame = function () {};
function countDownTimer(minute, tX, tY) {
minute = minute;
seconds = 4;
myCountDown = function () {
seconds--;
};
function myCallBack() {
trace("ok, completed");
if (_root.result_mc.hitTest(_root.fans_mc.xyz01)) {
trace("01 Collision Detected");
_root.countDown.result.text = "01 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz02)) {
trace("02 Collision Detected");
_root.countDown.result.text = "02 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz03)) {
trace("03 Collision Detected");
_root.countDown.result.text = "03 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz04)) {
trace("04 Collision Detected");
_root.countDown.result.text = "04 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz05)) {
trace("05 Collision Detected");
_root.countDown.result.text = "05 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz06)) {
trace("06 Collision Detected");
_root.countDown.result.text = "06 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz07)) {
trace("07 Collision Detected");
_root.countDown.result.text = "07 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz08)) {
trace("08 Collision Detected");
_root.countDown.result.text = "08 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz09)) {
trace("09 Collision Detected");
_root.countDown.result.text = "09 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz10)) {
trace("10 Collision Detected");
_root.countDown.result.text = "10 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz11)) {
trace("11 Collision Detected");
_root.countDown.result.text = "11 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz12)) {
trace("12 Collision Detected");
_root.countDown.result.text = "12 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz13)) {
trace("13 Collision Detected");
_root.countDown.result.text = "13 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz14)) {
trace("14 Collision Detected");
_root.countDown.result.text = "14 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz15)) {
trace("15 Collision Detected");
_root.countDown.result.text = "15 Collision Detected"
} else if (_root.result_mc.hitTest(_root.fans_mc.xyz16)) {
trace("16 Collision Detected");
_root.countDown.result.text = "16 Collision Detected"
}
}
function powerspin() {
var randomizer:Number = 0.654654;
trace("foo");
trace("inputMic.activityLevel : "+inputMic.activityLevel);
trace("360.000*inputMic.activityLevel*randomizer : "+360.000*inputMic.activityLevel*randomizer);
_root.fans_mc.rotateTo(360.000*inputMic.activityLevel*randomizer,4,"easeInOutQuart");
_root.boxtemp.tween("_alpha",100,6,"linear",0,myCallBack);
}
countInterval = setInterval(myCountDown, 1000);
this.onEnterFrame = function() {
_root.countDown.myResult.text = inputMic.activityLevel+"%";
percent = inputMic.activityLevel;
if (percent<=50) {
_root.pin._rotation = (360/100)*percent;
} else {
_root.pin._rotation = 180;
_root.pin._rotation = (360/100)*(percent-50);
}
if (seconds<10) {
_root.countDown.myTextField.text = minute-1+":"+"0"+seconds;
} else {
_root.countDown.myTextField.text = minute-1+":"+seconds;
}
if (seconds == 0) {
clearInterval(countInterval);
seconds = "0";
minuteDelay = setInterval(minuteChangeDelay, 1000);
}
if (_root.countDown.myTextField.text == "0:00") {
delete this.onEnterFrame;
_root.countDown.myResult.text = inputMic.activityLevel+"%";
_root.countDown.myTextField.text = "Time Up!";
powerspin();
}
background_mc._alpha = 0+speed;
if (speed<45 && inputMic.activityLevel>30) {
speed = speed+inputMic.activityLevel*1.000000E-001;
}
if (speed>0) {
speed = speed-5.000000E-001;
} else {
speed = 0;
}
};
minuteChangeDelay = function () {
minute--;
seconds = 59;
countInterval = setInterval(myCountDown, 1000);
clearInterval(minuteDelay);
};
}
countDownTimer(1,10,10);
it’s my first time at gamedevelopment, so any improvement suggestions accepted… :shock: