ActionScript 2.0 :: Using Loop To Create Sound Object?
Aug 18, 2009why does this not working?
for (i=0; i<=numVoices; i++) {
var this["voice"+i]:Sound= new Sound();
}
[code]......
why does this not working?
for (i=0; i<=numVoices; i++) {
var this["voice"+i]:Sound= new Sound();
}
[code]......
Is there any AS3 library or code-snippet that can create altered versions of a Sound object on-the-fly (at runtime)? Either based on:
An existing Sound object; A ByteArray object;
For example, say you have a "dry" sound of a gun-shot. You could:
[Code]...
how to use actionscript loops to loop things, like sounds for example. Can someone show me how to create an infinit loop for a sound. If you can a step by step thing would be nice since i am a TOTAL newb at actionscript, i can do the other things in flash but the actionscript messes me up. And for the loops, what frame do i put it in in the actionscript if i want to to go throught the entire scene?
View 6 RepliesHow can I load sounds using a loop? As there are around 20 sound files named something like s1.mp3, s2.mp3......sn.mp3
We can load sounds and create dynamic sound object in AS2 something like this:
ActionScript Code:
for(n=1;n<=20;n++){
_root["s"+n]=new Sound();
_root["s"+n].loadSound("s"+n+".mp3");
}
Is there anyway in AS3 to create dynamic sound objects?
I'm building a web flash 8 app with an animated nurse that talks and help the user in different events. the voices sit in a external folder and i load them using load sound method. It works fine as a desktop app, but when testing the movie on slow download (DSL 32 KB/s) I realized that i must load all the sound before i can play the animation.
problem nr.1: How do i create folowing sound objects (voice_0, voice_1, voice_2..) using a loop?
I've tried this, but it doesn't work
for (i=0;i<numVoices;i++)
{
var this["voice_"+i]:Sound=new Sound;
}
[Code]....
Here's a piece of script I would like to condense into a single loop where the number of instances created would be dynamic:
Actionscript Code:
//create instances of Door objectvar door_1:Door = new Door();var door_2:Door = new Door();var door_3:Door = new Door();var door_4:Door = new Door();var door_5:Door = new
[code]....
How to create sound object dynamically in one movieClip.
Example
for(i=1;i<5;i++){var sound + i = new Sound();}
I want to store the bitmap data from _sampleTile in array, but I was wondering how to increase the performance. If I do it like this:
var _sampleTile:BitmapData;
var _arrayLenght:int = _tileClipArray.length;
for(var i:int = 0; i < _arrayLenght; ++i){
[code].....
Exactly this doesn't work but is there a way to do it?
Code:
for ( var i = 0; i < 10; i++ )
{
var ["object"+i]:MyClass = new MyClass();
// would create object1, object2, object 3, object 4, ...
}
I would like to create a loop so the icons in the menu continually loop indefinitly.[code]
View 2 RepliesI am attempting to use a loop to create text field with the loop's current value. The code looks like this:
ActionScript Code:
for (var i = 1; i<=10; i++) {
var 'nameHolder'+[i]+'_txt':TLFTextField = new TLFTextField();
'nameHolder'+[i]+'_txt'.x = 40
'nameHolder'+[i]+'_txt'.y = 40
'nameHolder'+[i]+'_txt'.text = "Hello World"
}
So essentially what it should do is create 10 text fields at 40, 40 with the text: "Hello World".
It's possible to play a sound file through AS, either by loading it from a folder or import it to flash. It's also possible to play a dynamic tone with flash.media.Sound + writeFloat.
But... is it possible to play a sound file with flash.media.Sound + writeFloat in some way? I want to play a sound file without having to deal with any files except the .swf!
I am using the following to extract the byte info from a sound object - however if I go back to the same sound object and run this again, The byteArray has no bytes available.
var data:ByteArray = new ByteArray;
sound.extract(data,sound.length*44.1);
data.position = 0;
return data;
Is this the correct behavior? Is there not a way to do this multiple times on the same sound object?
I have been at this for about 19 hours straight! I am going to go to bed immediately after this post, but for crying out loud, I have NEVER had this problem before today! Before anyone reads ahead and says 'you have to attach your sound object to a completely separate mc to be able to control it independently from all other sound/root volumes.' see if the following code accomplishes just that:
[Code]...
Is it possible to take two Sound objects and combine them into one Sound object so that one Sound plays, and then the second plays right after it? I can just play the first Sound and then the next right after it, but it would be much cleaner to combine them before playing the audio.
View 1 RepliesI have a streaming sound that is loaded into my flash movie (will end up on CD) that is very distorted, it sounds like someone is slowing down the audio, the voice sounds deep and slow
View 1 RepliesI'm using this code to play/stop a sound in my flash movie, but I can't figure out how to make it loop. What do I need to do?[code]
View 3 RepliesI have CS4 but saving doc as CS3 so I hope I am in the right forum. I added a behavior as sound streaming mp3. I want to loop it.. Here is the action code that was generated. How would I change it to looping. I changed the true to false at the end of the code but that didn't work. here it is:
//Load Streaming mp3 behavior if(_global.Behaviors == null)_global.Behaviors = {}; if(_global.Behaviors.Sound == null)_global.Behaviors.Sound = {}; if(typeof this.createEmptyMovieClip == 'undefined'){ this._parent.createEmptyMovieClip('BS_figaro',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) ); _global.Behaviors.Sound.figaro = new Sound(this._parent.BS_figaro);
[code]....
How can I loop a sound without the gap? If i try
ActionScript Code:
play(song, 100);
it will have a gap everytime it loops, how can i fix that?
I have managed to get my sound playing from the library but would like to know what the simplest way to loop the sound in as3 would be, (using the smallest amount of code as possible preferably!)
View 3 RepliesI added a behavior as sound streaming mp3. I want to loop it.. Here is the action code that was generated. How would I change it to looping. I changed the true to false at the end of the code but that didn't work.here it is:
//Load Streaming mp3 behavior
if(_global.Behaviors == null)_global.Behaviors = {};
if(_global.Behaviors.Sound == null)_global.Behaviors.Sound = {};
[code]......
how to continuously loop a sound, but all I have seen is aSound.play(0,1000);Not really a continueous loop. I was looking at watching for one of the COMPLETE dispatches (from the Sound object, or from the SoundChannel object), then start the sound again. The only thing is would this not start another channel?
View 3 RepliesHow do I get this sound to loop?
"sonido1" - my mp3
Code:
stop();
import com.greensock.TweenMax;
import com.greensock.easing.*
function love() {
TweenMax.to(sonido1, 1, {volume:1, delay:0.5});
[Code] .....
So, I downloaded a simple sound loop from Flash Kit.
I am building a Flash webiste and want the sound to loop once the movie loads. I have added a stop and play button to the movie in case the viewer doesn't want the sound on. I understand sound can be annoying.
I add the following code to the FRAME 1 of the movie. Everything works fine but when the loop finishes, it just stops. How do I get it to continue looping? Also, as I navigate to other sections of the movie.. I want it to continue playing and not restart when I go back to say "Home". Home starts at frame 1 as well.[code]...
ok so im having an issue with Flash CS5.I have a sound looping, and my animation is only 13 frames long, while the song is like a minute long, so each time the animation loops threw the default "Loop Playback" a new sound audio is played which os overlapping the previous over and over causing a massive echo effect.Whats the best way to loop both of them insync, or atleast copy and paste the animations frames and make it the length of the song?
View 1 RepliesI have created a button which plays an external MP3 file, but the first problem is it only plays once. What script do i have to add so the sound continually loops. Secondly, I have created a button which stops music, but I can't figure out the code which stops the MP3 file playing. I've tried backMusic.close();, but an error message is displayed as the sound is already loaded up.
Heres the ActionScript Code:
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.text.*;
[Code] .....
Is there some secret to attaching sound via a loop? I have had to hard code this and write it out 26 times.
Here's what I want:
ActionScript Code:
for(k=1;k<=26;k++)
{
[Code]....
I've tried it with _root, without, using a variable such as moji = eval("moji"+k) then moji.onPress, but nothing works. It just won't play the sound unless it's hard coded.
In the tutorials, there is a sound loop that you start with a button, The fla didn't have a stop script to add to a second button.
View 4 RepliesI don't know why, but my sound dosn't loop, even though I set it to loop, here is the complete code: This is on my 1st frame:
[AS]
bg_music = new Sound(_root);
bg_music.loadSound("music.mp3", true);
bg_music.stop();
[/AS]
This is on my sound controller clip, shows the progress of the music playing and stuff:
[AS]
onClipEvent (enterFrame) {
var musicloaded = _root.bg_music.getBytesLoaded();
var musictotal = _root.bg_music.getBytesTotal();
var lprogress = Math.round((musicloaded / musictotal) * 100);
var musicttime = _root.bg_music.duration;
[Code] .....
I tried with "loop" too, but the sound just plays once.
can anyone tell me how to loop 5 different sounds, drums, bass, sax etc. When i use :
[Code]...
and play them all, it's ok, looping fine, but what i want to do is to have 5 buttons that control those 5 sounds. turning of and on some of them... i tried with "secondSound.setVolume(0)" to turn off 2nd sound, but that kill them all... CAN i SOMEHOW set volume down just for one sound? OR if thats not possible, i need bass or sax sound to start again, when button is clicked, in the same position where drums sound is...
but when loop start again to start also from "0" i've also tried reading firstsound position:
[Code]...