mr. anton azarov i have new problem
I build learning application using randomized sound, but sometimes that comes out about the repeated.
how that problem is not repeated
my code
import flash.media.Sound;
import flash.events.MouseEvent;
import flash.media.SoundChannel;
stop();
var tanya:Array = [suara_a,suara_b,suara_c,suara_d,suara_e];
var jawab:Array = [["A", "D", "C", "B"], ["B", "G", "J", "P"], ["C", "J", "O", "E"], ["D", "V", "T", "Q"], ["E", "W", "M", "P"]];
var so:Sound;
var sc:SoundChannel = new SoundChannel();
b.visible = false;
s.visible = false;
var no = 0;
var acak1;
var acak2;
var jawab_benar = 0;
var jawab_salah = 0;
ganti();
function enable_disable(a)
{
if (a == 0)
{
pa.mouseEnabled = false;
pb.mouseEnabled = false;
pc.mouseEnabled = false;
pd.mouseEnabled = false;
n.mouseEnabled = true;
}
if (a == 1)
{
pa.mouseEnabled = true;
pb.mouseEnabled = true;
pc.mouseEnabled = true;
pd.mouseEnabled = true;
n.mouseEnabled = false;
}
}
n.addEventListener(MouseEvent.CLICK, hnex);
function hnex(Event:MouseEvent)
{
no++;
ganti();
}
function ganti()
{
if (b.visible)
{
jawab_benar++;
}
if (s.visible)
{
jawab_salah++;
}
if (no == 5)
{
gotoAndStop(2);
}
else
{
acak1 = Math.ceil(Math.random() * 4);
acak2 = Math.ceil(Math.random() * tanya.length) - 1;
sc.stop();
b.visible = false;
s.visible = false;
so = new tanya[acak2]();
sc=so.play();
enable_disable(1);
if (acak1 == 1)
{
pa.text = jawab[acak2][0];
pb.text = jawab[acak2][1];
pc.text = jawab[acak2][2];
pd.text = jawab[acak2][3];
}
if (acak1 == 2)
{
pa.text = jawab[acak2][1];
pb.text = jawab[acak2][0];
pc.text = jawab[acak2][3];
pd.text = jawab[acak2][2];
}
if (acak1 == 3)
{
pa.text = jawab[acak2][2];
pb.text = jawab[acak2][3];
pc.text = jawab[acak2][0];
pd.text = jawab[acak2][1];
}
if (acak1 == 4)
{
pa.text = jawab[acak2][3];
pb.text = jawab[acak2][2];
pc.text = jawab[acak2][1];
pd.text = jawab[acak2][0];
}
}
}
rep.addEventListener(MouseEvent.CLICK, hrep)
function hrep(e:MouseEvent):void
{
sc=so.play();
}
pa.addEventListener(MouseEvent.CLICK, hpa);
pb.addEventListener(MouseEvent.CLICK, hpb);
pc.addEventListener(MouseEvent.CLICK, hpc);
pd.addEventListener(MouseEvent.CLICK, hpd);
function hpa(eventObject:MouseEvent)
{
enable_disable(0);
if (acak1 == 1)
{
b.visible = true;
b.y = 200;
}
else
{
s.visible = true;
s.y = 200;
}
}
function hpb(eventObject:MouseEvent)
{
enable_disable(0);
if (acak1 == 2)
{
b.visible = true;
b.y = 200;
}
else
{
s.visible = true;
s.y = 200;
}
}
function hpc(eventObject:MouseEvent)
{
enable_disable(0);
if (acak1 == 3)
{
b.visible = true;
b.y = 200;
}
else
{
s.visible = true;
s.y = 200;
}
}
function hpd(eventObject:MouseEvent)
{
enable_disable(0);
if (acak1 == 4)
{
b.visible = true;
b.y = 200;
}
else
{
s.visible = true;
s.y = 200;
}
}