PDA

View Full Version : button to play random number +sound help


jinackman
08-08-2009, 11:47 AM
Hi
i have just followed a tutorial on random number which plays mp3 files, so if random number is 3 it plays sound file sound3.mp3 and so on.
the tutorial can be seen here
http://www.webdesign.org/web/flash-&-swish/flash-tutorials/sounding-random-with-flash-cs3.14609.html

the problem is when i click the button i get a different number but no sound, i keep getting this error.

Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
at sound_fla::MainTimeline/playSound()

i have loaded all the mp3 files into the libary can't seem to find the problem.
iam new to actionscript please help
here is my actionscript code.

button.addEventListener(MouseEvent.CLICK, playSound);

function playSound(e:Event)
{

SoundMixer.stopAll();
var num:Number = Math.ceil(Math.random()*4);
bigNum.text = num.toString();
var path:String = "sound" + bigNum.text + ".mp3";
var s:Sound = new Sound(new URLRequest(path));
s:play();
}

eggnogg
08-09-2009, 03:59 AM
hi man
i dont know what that error means but if you google the error number alot of information comes up that can probably help you
good luck
eggnogg

jinackman
08-09-2009, 11:30 AM
Hi
i tried to google the error but couuldn't find anything to help me

anyone know what it might be
thankyou

sk_86
08-11-2009, 05:43 PM
Hi
i have just followed a tutorial on random number which plays mp3 files, so if random number is 3 it plays sound file sound3.mp3 and so on.
the tutorial can be seen here
http://www.webdesign.org/web/flash-&-swish/flash-tutorials/sounding-random-with-flash-cs3.14609.html

the problem is when i click the button i get a different number but no sound, i keep getting this error.

Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
at sound_fla::MainTimeline/playSound()

i have loaded all the mp3 files into the libary can't seem to find the problem.
iam new to actionscript please help
here is my actionscript code.

button.addEventListener(MouseEvent.CLICK, playSound);

function playSound(e:Event)
{

SoundMixer.stopAll();
var num:Number = Math.ceil(Math.random()*4);
bigNum.text = num.toString();
var path:String = "sound" + bigNum.text + ".mp3";
var s:Sound = new Sound(new URLRequest(path));
s:play();
}

first double check to see if all your file names are named correctly. how many sound files do you have? what u can do is make a random number generator (google random number function) with min and max parameters. the min and max will be a range and all the sound file u have so 1-10 if ur sound files are named 1-10. also run a trace statement in underneath the path and above the s variable to see what the name of the path is and make sure it is correct. if the path is correct then it has to do with something else. let me know how it goes
gluck

phredau
10-22-2009, 09:30 AM
JUST make sure that tye mp3 files are in the same folder that the .mp3 files are located in


button.addEventListener(MouseEvent.CLICK, playSound);

function playSound(e:Event)
{
SoundMixer.stopAll();
var num:Number = Math.ceil(Math.random()*6)
bigNum.text = num.toString();
var path:String = bigNum.text + ".mp3";
var s:Sound = new Sound(new URLRequest(path));
s.play();