ActionScript 3.0 :: Sound.play() Always Creates A New SoundChannel?
Nov 23, 2009
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.
View 3 Replies
Similar Posts:
May 3, 2011
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();
View 1 Replies
May 4, 2011
The 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?
View 2 Replies
Apr 17, 2009
I 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
Apr 10, 2010
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.
View 1 Replies
Apr 5, 2010
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]....
View 2 Replies
Aug 9, 2011
How do we check if there is a sound already playing in a soundchannel?
View 1 Replies
May 3, 2011
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 Replies
May 3, 2011
I'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..
View 2 Replies
Dec 6, 2008
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!...
View 2 Replies
May 28, 2008
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 Replies
Jan 20, 2010
I 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]....
View 2 Replies
Oct 23, 2010
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?
View 1 Replies
Nov 3, 2005
i need to combine these two scripte (first one creates array to play movie clips in a order fro left to right of the screen depending on position ) each script works corectly if used on there own. but i want to combine them
var videos:Array = new Array("mc1", "mc2", "mc3", "mc4");
var busy:Boolean = false;
for(var i = 0; i<videos.length; i++)[code]....
View 1 Replies
Oct 14, 2009
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!
View 9 Replies
Feb 13, 2007
i want to make a single button to play a sound, and if pressed again, stop the sound. and if pressed again, play the sound, and so on...
i know it has to be made with a boolean variable, true/false, but i just can't figure out how.
View 13 Replies
Mar 6, 2009
I'm trying to add sound to some buttons. It's just a little metallic 'klink' sound that plays on rollover. I only want the sound to play on the 'Over' state. So I've set up a layer (just for sound) for the button and I add my sound in the 2nd frame (the Over state). Everything is cool. All is good. And the sound plays on rollover. But the sound also plays when I click the button (i.e. it also plays on the "Down" state). Why? The Down state keyframe is completely empty. What's going on here? I've only put the sound in the "Over" keyframe, why does it also play in the "Down" frame (or when I click)?
View 1 Replies
May 17, 2003
I want to use a sound loop in my flash movie. The movie has many scenes. And the problem is that when I go to next scene or different scene I hear the sound repeating twice. I mean sound does not stop from first scene and begins from the different scenes.Is there any way to play sound like "stop all sound" option in Flash.
View 6 Replies
Mar 16, 2009
I have to play a sound file and show the progress of the sound file being played. I am using import flash.media.Sound; import flash.media.SoundChannel; But the PROGRESS event gives theprogress of loading of file. I want to know of much of the song has been played and how much more is left.
View 3 Replies
Aug 9, 2004
I am new to actionscript. I have created a script that will play server side sound object and client side mp3 files alternately. Now, I would like to play the client side mp3 first then only play server side sound object alternately. However, I have no idea how can I do so. The following is the code that need to be swapped:
[Code].....
View 2 Replies
Jan 25, 2011
I am trying to build a simple xml based mp3 player for a project. I have got as far as combo/list boxes populating.
The first time you click the a track to play it all is well.
However, when you click another track, the first stops, but then I get error message.[code]...
View 2 Replies
May 14, 2011
I tried modifying the sound in Action Script but now I do not get any sound on the webpage, only hear the sound in preview on flash editor.It was looping sound on the web page and I did not want to have surfers having to hit the stop button. But I did want it to play just once.[code]
View 1 Replies
Feb 14, 2012
I have a "onRelease function"
CODE:
btn_4.onRelease = function () {
var yTween = new mx.transitions.Tween(slider, "_x", mx.transitions.easing.Strong.easeOut, slider._x, 695 , 0.600000, true);
}
This works good but I like to add in a "onRelease" play sound, too. How it have to look like and where do I have to place the sound? Because: When I add in a new function "onRelease" both block each other.
View 2 Replies
Dec 14, 2009
I have two files as: A.swf and B.swf.[code]While I am playing B.swf then music is plays perfectly. While I load it to in A.swf then music in not playing.I don't want to change anything in B.swf like new Sound(this). I want actionscript code only for A.swf.
View 5 Replies
Jan 21, 2010
I've got 3 swf files and they are all nested. Here's the structure: [code]The sound clip "m1p1" is loaded in the library of "cc_mod1_shell.swf".This setup works when I just test "cc_mod1_shell.swf". I can hear the sound clip. But, when I test the root level "cc_ shell. swf", the sound does not play. Can anyone tell me what I'm doing wrong? Why would this._ parent work when I'm just using the 2 files in question, and not when they are nested in another file?.
View 7 Replies
Mar 27, 2012
How do you get sound to play?
I am importing the sound and exporting in with an identifier "sjump".
I am trying to play the sound from a seperate .as file with the following code:
var sound_sjump:Sound = new Sound();sound_sjump.attachSound("sjump");sound_sju mp.start(1,0);
Why won't it play?!
Some of my sounds like if I attach "coin" instead of "sjump" work? Why is this?
View 3 Replies
Sep 7, 2008
I have a Flash movie that uses the following code to load a Sound from the library[code]...
View 4 Replies
Jan 28, 2009
trying to make a play/pause toggle button in AS3. I'm a newbie but I've finished the site except for this element. my audio file works when i import to the library and it plays it in the preview. its in the same folder as the fla. working in cs3. This is what i've done.new as3 file. code.
var req:URLRequest = new URLRequest("ocean.mp3");
var s:Sound = new Sound(req);
s.play();
whats the deal? I get no compiler errors. i'm hitting option+Return on the mac to test the movie. I downloaded some one else's and it worked. i copied theirs into my project and it didn't work. i have a feeling its something to do with classes that i don't know about
View 1 Replies
May 2, 2010
I'm working on a game that loops a random sound file everytime the user goes to the menu. When I tried the simulate download in the preview menu, it took a long time to load the first frame (which is a preloader). I found the problem was that in the linkage for the sound files I said "Export on first frame" so i unchecked that box, but then when I tried playing again, the sound wouldn't load.So, I'm wondering, is there a way to play sound files through ActionScript without having to load them on the first frame?
View 1 Replies
Feb 25, 2009
are there any possibilities to play sound in flash (actionscript 2), which is defined by a mathematical function like f(t) = 0.5*sin(2*Math.pi*16/27*440*t) ?
View 2 Replies