ActionScript 3.0 :: Random Sound With An Array?
Dec 23, 2009
I would like to use an array to play 5 sound files randomly.Here's the code I've got so far! Can anyone tell me what code I'm missing?
var my_sounds:Array = [Sound1, Sound2, Sound3, Sound4, Sound5];
var s1:Sound = new Sound(new URLRequest("GentleSeaOnFlatBeach.wav"));var s2:Sound = new Sound(new URLRequest("SPLASH.wav"));var s3:Sound = new Sound(new
[code]......
View 1 Replies
Similar Posts:
Mar 22, 2009
I have 30 sound clips, each named s1, s2, s3 etc...
i want to create an array so when it enters the frame it will play a random sound from the array.
View 1 Replies
Jan 4, 2010
I have a foreign language resource which randomly creates and displays a number. The player then needs to select the correct number in a particular foreign language. What i also need to do is play the audio for the randomly created number. I have numbers 13-20 all as seperate sound files also named as identifier names 13,14,15 etc up to 20.
The following script loads the sounds. Sound1 is the sound which needs to hold the random number which is generated:
ActionScript Code:
onClipEvent(load){
Sound1 = new Sound();
rndClip = ????????;
[Code]....
I need to load this array as Sound1 so that the correct sound file plays to match the random number.
View 2 Replies
Dec 16, 2005
I'm trying to load sound dynamically into a clip and then play it randomly. The AS I came up with works great if the sound is embedded and I use the .attachSound() method instead of loadSound(). Now, when I load it dynamically and use the code below, the sound plays very fast and at a higher pitch.
Code:
var crows = new Sound(this);
crows.loadSound("Raven.mp3", false);
crows.setVolume(100);
[Code].....
View 1 Replies
Sep 30, 2006
I want a movieclip consisting of a dynamic text box that, from the time it's loaded onto the stage, loads a randomly selected text string from an array, and continues to loop until the clip is removed from the stage. I also want the text strings to appear in the text box for random intervals between 500 and 3000 milliseconds.
While I've found tutorials here and elsewhere on loading one element from an array, usually triggered by a button, I don't know how to combine/alter it with the other elements.So I want this movieclip on the stage randomly flashing phrases from an array, some for a barely perceptible time, and others for a readable time.
View 3 Replies
Feb 11, 2009
I've been putting data into an array via XML, and then selecting at random an image string to load in a pic at random. But whilst doing this, I wanted to remove the String from the Array that I have just used, so I don't get repetition of the same image in the output. I initially thought that pop would remove the string I had just used - But of course it Removes the last value in the Array instead, which doesn't really help.
Ok - so how about randomizing the data once inside the Array, after it has been pulled in from XML!? That way I can load in the 'last' image, and then pop it out! Keeping a randomized selection of images each time 'it' is loaded
View 2 Replies
Oct 20, 2010
I've spent the last few days trying to find an answer to this seemingly simple question, and no luck. Well, partial luck, but not quite what I wanted.
My problem is this - I want to play a random sound when an event happens. In AS2, I used to do this[code]...
View 5 Replies
Oct 19, 2011
I'm working on a new AS3 project in Flash CS4. This is my second major project, and for some reason, when I enter a new frame, a sound from my library plays when it's not supposed to. It plays once, when I enter the frame. The thing is, there's no code that would initiate it to do so. In my first major project, it did the same thing. I figured I screwed something up since it was my first project, and ignored it -[code]...
View 9 Replies
Dec 19, 2006
Anyone know how to make a sound (picked at random from a selection in the library) play when a button is clicked?
View 2 Replies
Mar 3, 2007
I am working on a piece now that will have 10 invisible MC's (1-10) stacked on frame 1 in seperate layers that function like buttons on the main timeline. Each of these mc's will trigger a corresponding mc (A-J) to become visible and play and also start a sound file. This I have all worked out.
What I am writing about is a random function. When 1 triggers A, I would like one of five distinct MC's inside of A to be randomly selected to play, both with sound and with image.
Right now I'm working on the random function with sound, and I'm in need of soome assistance. I'm not sure of my approach, but why I'm stuck in particular now is because ususally when attaching a sound to an MC, when the sound is called it is through the name of the sound rather than the mc name and as I've created a random function I can't very well call the sound name as then it won't be random. Here's what I've got:
sound1 = new Sound(soundHolder1_mc);
sound1.attachSound("chime");
sound2 = new Sound(soundHolder2_mc);
sound2.attachSound("psychic");
[code]...
View 1 Replies
Aug 26, 2009
I was wondering if somebody could point me in the right direction to be able to load in a random sound clip (from a set of 5 or more mp3s) when the user rolls over a button. I can't seem to find a way to do this.
View 14 Replies
Mar 25, 2002
i am trying to write a script that generates a random sound. i like to make it a framescript but i am not sure how to do this, so i appended it to a movieclip (see below) but this doesn't work..
onClipEvent (enterFrame) {
randy = random(5);
if (randy=1) {[code]....
View 5 Replies
Feb 16, 2009
I'm looking for a way to play a sound with slightly altering pitch to make it more "interesting" (read: tolerable).
I've previously used it with great results in java programming with the Slick library. Simply asked the sound to be played at 0.9 - 1.1 of original pitch (1 = default), gave a subtle but awesome effect.
View 0 Replies
Apr 23, 2010
I've designed an interactive quiz that has 10 questions, and for each question 3 possible answers (obviously only one of which is right), however I'd like to add some sound to certain questions and a small video clip. The only issue I'm having, and I've not been able to get my head around. I've loaded all the questions and answers into arrays, and used the random function to display them in a different order each time, and because of this I'm having trouble figuring out how I'll be able to implement the use of sound and video into the project.
I'll post the code so far below as to give a better idea of what I'm trying to do, and what I've done so far.
Frame containing Array function:
[Code].....
View 0 Replies
Aug 15, 2005
I have to design a game for a school project that I have to redo to pass my year, but so far I have encountered several problems. My game is for children from 6 to 8 years old, so the game has to have a lot of sound (voice recordings) to explain the menus and the stuff they have to do.
[Code]...
View 8 Replies
Aug 28, 2007
I have a code that randomly generates a random sentence:[code]...Now on every word, I have a sound clip that I want to play, but how would I code it? I dont know I would I would assign a sound to a word or how to incorporate it into the coding above
PHP Code:
if(name "example"){mysound = new Sound();mysound.attachSound("example");mysound.start();}
[code].....
View 1 Replies
Apr 18, 2011
I am a voice over artist and I'd like to have a button and when you click it, it loads one of say 20 mp3s stored...wherever. It can be in the flash movie itself...but I'd rather the script access a directory on my server, that way the movie itself doesn't take long to load.
View 2 Replies
Dec 22, 2010
How can I make an array in flash as2 and from there select 12 values assigning them to twelve different variables?So far I got this:
quotes = new Array();
quotes[0] = "one";
quotes[1] = "two";
[code]....
View 2 Replies
Aug 27, 2010
I've got the following script that loops an array of movieclips at random positions in and out of the stage using Tweener. My problem is that the loop uses all the movieclips (WELCOME00, WELCOME01, etc.) at once. What I'd like is for the loop to only use one of the movieclips, chosen at random, for the loop instead of all of the movieclips listed in the array at one time.
Code:
import caurina.transitions.*;
var mcArray:Array = [WELCOME00, WELCOME01, WELCOME02, WELCOME03];
var init:Boolean = true;
[Code].....
View 3 Replies
Jan 8, 2011
I have an assignment where I need to create an array with 9 numbers between 1 and 34, also none of the numbers need to appear twice.This is what I have so far, so as you can see I'm stuck on the part where I have to check if the number already exists in the array.[code]
View 5 Replies
Mar 6, 2005
I have 12 empty Movie clips on stage. I want to get the content (jpg's or swf's) for these containers from an array. This is all fine, but I would like the contents to be loaded randomly into one of the 12 containers. The containers load the jpg's, which are preview thumbnails that need to link to the actual larger image plus some text. Loading eveything is OK, but I haven't figured out how to load the content into a random MC...
I attached the fla and images.
View 3 Replies
Jan 15, 2006
I'm creating a series of banners for a website. There are 3 so far with more to be made. I have made each banner as a separate swf file.The thing I would like it to do it create a randomly ordered array of the banner swf names and then load the banners in that order. Once the banners have been played or loaded through, I would l simply like it repeat that same order again.I have managed to create an array and play through that array in an ordered loop, but how do I create a random array that will do the same thing?[code]
View 1 Replies
Aug 25, 2006
I have problem with getting a random word from an array and the putting that word to a text field.
I setup the array for my words like this:
Code:
// a string of words
this.somewords = "wind breeze storm stormy tornado text space";
// convert the string of words into an array of words
this.wordList = new Array();
this.wordList = this.somewords.split(" ");
And I want to put randomly these words to a movieclip that I'm attaching to the stage about 50 times.
View 3 Replies
Feb 10, 2007
What should I do so I end up with an array of random numbers like
[2, 6, 4, 9, 0, 3, 7, 8, 1, 5]
[3, 5, 8, 1, 9, 0, 6, 7, 2, 4]
I'm thinking like starting with an ordered array
[code]......
View 2 Replies
Aug 1, 2007
I'm trying to create a program that creates a random map for a side scrolling cave. So I need to store the roof and the grounds y coordinate into a big array, like 10 000 pieces of wall.
The only way I've gotten it to accept some data into the array is like this but I want something cleaner and something that can go on forever.
How should I format the first 4 lines of code so that the array accepts commands like this and expands for the for loop as needed?
[Code]....
View 1 Replies
Jan 21, 2008
Pattern_Array (created by a random function that pulls from Words_Array and stores the index)Now I want to create another array called Choices_Array that will compare Pattern_ Array to Words_Array and not repeat any of the Pattern_Array index's in the new array.
View 1 Replies
Aug 7, 2008
I have an Array Randomly loading images on to the stage, there is a 'splice'so no 2 images repeat. the problem is - once the images all get 'deleted' there are no more images the array can pull. I want the images to be recreated in the array.That way It will load the 29 images I have Randomly, with out repeating them and after all 29 appear it will start over again.If I remove the 'splice' I can load as many images as I want however some load twice or more before the batch is complete.
Code:
var images:Array = new Array();
for (var i:Number = 0; i < 29; i++) {
images.push("image" + i + ".jpg");[code].....
View 1 Replies
Nov 19, 2009
I've been using the following script to randomly display options for a quiz similar to who wants to be a millionaire:
Code:
var answersArray:Array = new Array("Geography", "Maths", "English", "French");
var correctAnswer:String = answersArray[0];
[code].....
View 2 Replies
Jun 18, 2010
I'm trying to create a list with an array..My purpose is to put array elements randomly in to the list..But the catch is, I want one array item to assign with 2 list objects..I mean.My arrray is : ["1","2"]And my list is this : "A", "B", "C", "D""A1", "B2", "C2", "D1"
View 1 Replies
Mar 6, 2005
I have 12 empty Movie clips on stage. I want to get the content (jpg's or swf's) for these containers from an array. This is all fine, but I would like the contents to be loaded randomly into one of the 12 containers.The containers load the jpg's, which are preview thumbnails that need to link to the actual larger image plus some text. Loading eveything is OK, but I haven't figured out how to load the content into a random MC
View 3 Replies