ActionScript 3.0 :: Check Sound Already Playing In A Soundchannel?
Aug 9, 2011How do we check if there is a sound already playing in a soundchannel?
View 1 RepliesHow do we check if there is a sound already playing in a soundchannel?
View 1 RepliesThe thing I don't understand is how to assign a sound to a soundchannel without playing the sound. All the examples I've seen do this.
Code:
_SoundChannel = _sound.play();
_SoundChannel.stop();
And how can I set a SoundChannel volume to zero before allocating a sound to it?
I would like to know if you can give me a direction how can I check if a movie clip is already instantiated, if it is, don't duplicated it, if it's not, create the object.I have an idea that it should be with an if statement I guess but I am not sure of the rest
View 1 RepliesHow do I check if my music is playing or not? I need this so I can let my loop loop forever.
View 4 RepliesIs there a way in AS3 to determine if a loaded sound file is still playing or not? I need to start an animation when a sound starts and stop the animation when the sound is done playing.
View 3 RepliesI wondered if there is a way to find out from the soundChannel the url of the sound it is currently playing. once I found out its url, i can than use its name to call something else.Or anyway to find out the sound that is playing on a soundChannel.I will know which channel to look into, but different sound will be loaded into this soundChannel.If this is not possible, i thinking along the line of overloading SoundChannel play method so that is fires an event when the sondchannel plays and also find out the name of the sound file it is currently playing.
View 2 Replies[Code]...
So the sound file's name in the Library is "1-welcome.wav", for the Linkage Properties, it is as follows: Class: "mySound", Base class: "flash.media.Sound", Export for ActionScript checked, Export in first frame checked. When i first renamed the Class in he Linkage Property i got: "A definition for this class could not be found in the classpath, so one will be automatically generated in the SWF file upon export."
As I have commented before I am building English teaching apps. I will have music playing in the background, words being pronounced and at times a surprise sentence. All three could sound at the same time at any given point. To build this properly should I use SoundChannel for all of these?
At the moment my code for the music loop is as so. The sound is in the library and exported for AS. Is this code fine or is it better to assign it to the SoundChannel class.
I have some sounds in my library that I want to play in a soundchannel, but how? This is what I have so far:
var music:Sound = new Sound();var channel:SoundChannel = new SoundChannel();var sTransform:SoundTransform = new SoundTransform();var sound:SoundFile1 = new SoundFile1(); // Note: SoundFile1 is a class; in it is my soundfile in the library// music.load(sound); ??channel = music.play();
Is there a better way to use the sound channel is AS3?
var mySound:Sound = new Sound();
playButton.addEventListener (MouseEvent.CLICK, myPlayButtonHandler);
var myChannel:SoundChannel = new SoundChannel();
function myPlayButtonHandler (e:MouseEvent):void {
[code]....
I've just started working with sound and as I understand it I primarily need two objects: Sound and SoundChannel. Every call to a Sound.play() method will create a new SoundChannel object. So technically, I could write my code like this:
Code:
package
{
import flash.media.Sound;
[code]....
Will simply create a new SoundChannel object and the first one created by the constructor will be garbage collected? As a side note, it's possible to see Adobe's source files e.g.SoundChannel.as. I'm curious as to how the SoundChannel.stop() method works since it doesn't throw an error or exception even if the audio has already stopped playing.
I have a soundchannel, and I'm playing a lot of sounds in it, but I need the completion of any sound file within that channel to be followed by a wait of two seconds, then trigger an event. How can I do this?
View 4 RepliesI'm planning to program a small piano in flash that have an x number of notes to play through a SoundChannel.
What I have not found is a way to record what is playing through SoundChannel and send it as byteArray to a server side script that will save it as WAV (or mp3).
I know Flash Player 10.1 allows you to record sound, but everything I have found is about recording sound using the microphone class. It seems the way to go is to send the sound data to the microphone. That doesn't seem very right or possible though..
I just finished a simple music player... For testing purposes. I upload it in the following address:http:[url]....with 10 music songs that I had recorded from radio stations(added the last 2 twice for testing).The problem is that when a song has totally loaded, stop action taken needs about 1 second to be applied!I.e. When I press "STOP", the sound continue to play for 1 sec before stop. When I push "pause" it takes one second for the music to stop!
However when using resume (second time pause) the sound starts instantly! Thus I guess there is an issue with stop()function of the SoundChannel object that I am using to stop the sound. Also notice that when unpause the music, it continue ~one second before the last sound - which means that I saved the soundChannel.position number (and also call soundChannel.stop()) in correct time, but it didn't stop immediately - bug!?
This only happens when the application runs through a browser(plugin v. 10) - programmed in CS3.
PS1. Notice that ,this also happens when I change Volume too. Thus because Stop and Volume are parts of SoundChannel, I guess there might be a bug with SoundChannel in online plugins..... :/
PS2. Notice that ,this also happens when I close the browser (firefox). Even if browser is closed the music continue for 1 sec the same way as when pressing stop!.. Thus I guess it's flash bug!...
I have a pause button that pauses a sound playing in a soundchannel. It works, but when I resume the sound, it isn't in thecorrect position, almost like it was rewinded a little. I'm usingthe code straight from the
View 1 RepliesI load a song and when I get the length the song never reach this value.Here is issue document by another guy AS3 - SoundChannel.position never reaches Sound.length.And here is my code
import flash.display.Sprite;
import flash.net.URLRequest;
import flash.media.Sound;[code]....
From the Flash player specification, it supported up to 15/16 or 32 sounds in a buffer, which mean any more sounds is load beyond that limit will either caused buffer stop working.
Is there any class to override to increase sounds to 1024 or greater?
I have a sound clip that I'm loading externally into my flash file. The code I'm using looks like this and is placed in the as layer on the first frame,
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
var myTransform = new SoundTransform();
var lastPosition:Number = 0;
mySound.load(new URLRequest("introaudio.mp3"));
myChannel = mySound.play();
[Code]....
I am creating a game that has 6 movieclips all on the main time line of the game. Each movie clip has three buttons that when clicked plays, pauses or stops a sound clip.When I press any of the sound clip play buttons that sound starts playing, the problem is when I click any of the other sound clip play buttons those sounds also start to play. Is there a way I can disable the other sound clip buttons while the current sound is playing then enable all of the buttons when the current sound has stopped.
This is the code that creates one of the sound objects
[Code]...
So I made a few buttons with sounds within them and when I publish it they work just fine. But what I want them to do is;
Say I click a Button.The sound starts playing.Then I click it again, before the sounds done playing.I want it to stop the playing sound and start playing the button I just clicked on, whether it be the same button, or a different one.Right now it just ends up sounds like an echo because it'll play it as many times as you click it.
I'm trying to play a sound using a technique found here (play the sound by sampling raw sound data gathered from the original with extract()), with the difference that the mp3 sound is embedded in the swf, not loaded externally. This is my code:
var soundBytes:ByteArray = new ByteArray();
var mp3sound:Sound = Sound(new Sound1_design()); // this is the embedded sound
mp3sound.extract(soundBytes, int.MAX_VALUE);
[Code]....
This works, in a way, except that the resulting sound is distorted (it has a kind of a metallic ring).
I am loading small sounds dynamically with the loadSound command. These small sounds are activated with a rollover. see script below. This works ok. however. i want the first sound to keep playing while the rollovers load sound. a bit like playing the piano. This works ok when i import all the sounds into the library and place them on their very own button. however the size of the flash movie increases to 140k. whereas when i load them dynamically the size of the movie is 20k. obviously i want to load dynamically.
But with dynamic loading each sound stops when another sound is rolled over, so that there is only ever one sound playing at once. I need to load the sound into a different level or something, so that the first sound can keep going while the smaller, shorter sounds play over the top. this is my script below. The first sound loads when the movie starts. This is the one i want to keep playing. Then there are the smaller ones with rollovers. does this make any sense? there's actually 13 little sounds.
[Code]...
ok so i have a button that plays an animation for fire when held down. and when realsed goes to and stops and frame one. when it reaches the end of the time line it goes to and plays at frame 10 and goes back to the end of the timeline. I have a sound for the fire animation that plays for the effect. The problem is the sound keeps going untill its over even if the button isnt held down. and when the playhead reaches the end of the timeline it goes to and plays and frame 10 and it replays the sound. if i hold it down it will just keep playing the sound over and over from start to finish. what i want it to do it when i hold the button down i want it to play the sound and when released it stops the sound where ever it is at. I also dont the sound to play again if there is a sound already going to stop it from playing 20 sounds at one time it gets loud and you need asprin after about 5 seconds of that.
View 2 RepliesI am trying to embed some sound controls, and have hit a dead end. I made my play and stop buttons, imported my mp3,, assigned it proper linkage, and inserted this AS2 :
[Code]...
The buttons are named "play_btn" and "stop_btn" respectively. When I export it or preview it, hitting the play button does not do anything.... I hear no sound. What could be up with this?
I'm using Flash 8 and new to actionscript and event listeners.
I have the following listener to check when the flv has stopped playing and set a couple of item to visible.[code]...
is there a way to check if a MC stopped playing?i have a MC on my stage and I guess I have to put some event on the last frame inside the MC. now I want that code to jump to frame X of the MAIN stage- not the MC itself. how do i do this?
View 3 Repliesis there a way how I can check if a clip is still playing or if it had a stop command an doesn't play anymore?
View 11 Repliesi got a STREAMING mp3 file in loaded by mySound.loadSound("test.mp3", true). and we all know that this function will run while sound completes
Code:
mySound.onSoundComplete = function(){
trace("Sound Completed")
}
and this one while the sound is FULLY loaded
[Code]...
well i know there is no such thing... but i think now u get my ideas is there any alternative way to do the similar thing? cuz since it's streaming mp3, the song will be played during the loading progress...so both onLoad and onSoundComplete won't work....
I have some effects which I use in my Flex app... They are all declared within mxml tags...
For example:
<mx:Fade id="fadeIn" alphaTo="1" duration="500"/>
<mx:Fade id="fadeOut" alphaTo="0" duration="500"/>
<mx:Move id="moveEffect" duration="500"/>
[code]....
Basically i have a mini map and i want to check what a mini map tile is playing at.
so i tried to trace it, thinking that the error i get was only because the tile was not yet instantiated i made the following function appear after 1 second to be safe.
[AS] function startGame(e:Event) {
trace(getChildByName("tile1").currentFrame);
}[/AS]
Still get the following error.
1119: Access of possibly undefined property currentFrame through a reference with static type flash.displayisplayObject.
I placed .x (just a test value) instead of .currentFrame and i receive no error.
I guess .currentFrame checks for the MovieClips timeline during compilation?