array question
i have game in each time click, sound heard.
the sounds in array of 12 sounds, , heard randomally.
i want write script not allow sound heard, not heard again, after 12 sounds, no sound heard,
this script wrote:
multitouch.inputmode = multitouchinputmode.touch_point;
import flash.display.*;
import flash.events.*;
import flash.media.sound;
var my_sound_baby:baby = new baby();
var my_sound_plane:plane = new plane();
var my_sound_drop:drop = new drop();
var my_sound_knife:knife = new knife();
var my_sound_drink:drink = new drink();
var my_sound_seesaw:seesaw = new seesaw();
var my_sound_glass:glass = new glass();
var my_sound_car:car = new car();
var my_sound_hammer:hammer = new hammer();
var my_sound_helicopter:helicopter = new helicopter();
var my_sound_toilet:toilet = new toilet();
var my_sound_train:train = new train();
var mychannel:soundchannel = new soundchannel();
sounds_click.addeventlistener(touchevent.touch_tap,play_sound);
function play_sound(touchevent){
var sound_array:array = [my_sound_baby,my_sound_plane,my_sound_drop,my_sound_knife,my_sound_drink,my_sound_seesaw ,
my_sound_glass,my_sound_car,my_sound_hammer,my_sound_helicopter,my_sound_toilet,my_sound_ train]
sound_array[math.floor(math.random() * 12)].play();
}
thanks
ehud
define , fill array outside of function. when play sound remove array using array.splice() method. when array empty remove event listener touch_tap cannot call function again.
More discussions in ActionScript 3
adobe
Comments
Post a Comment