ActionScript 3.0 :: Play An Instance Of A Sound In A Soundchannel
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
Similar Posts:
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
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
Oct 30, 2009
I am trying to call a method that pulls several variables depending upon the button clicked.Depending upon the button, it will play a certain sound/song. Below is what i have so far, if anyone could figure out why i get the following error: TypeError: Error #1034: Type Coercion failed: cannot convert "test_Btn12_soundChnl" to flash.media.SoundChannel."test_Btn12" is the button that i happened to click on at that time.
Code:
public function buttonClick(e:MouseEvent):void {
playSound(MovieClip(e.currentTarget), SoundChannel(String(e.currentTarget.name) +
[code].....
View 3 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
Jun 15, 2009
I'm using flash CS4. I am trying to make a piano. It will be the header of a web page when the mouse rolls over a key the appropriate note plays- ideally the key would appear to be pressed as well. I have a jpg of a piano keyboard imported as a graphic. On a new layer I have made a button whos over state has a blank keyframe. I have imported that button to the stage and given the instance a name. I have attached a sound to the over keyframe (middle C).
I have dropped a second instance of the button onto the stage and given it a unique name. When I attach the next sound (D pitch) to the over state it changes the original middle C. How can I get each instance of a button to play a unique sound? I have tried using a new layer for each button but that didnt work. Do I have to make a brand new button for each note? I have reduced my design to include only 16 notes (I originally wanted 32 but I thought that may take too long to download)---
View 7 Replies
Jul 27, 2010
Imagine this scenario:The application is a Game, where the enemy characters can 'attack' the player, and each time they attack the 'Attack.mp3 file is played from the libraryNow my question is, if I have to create a new instance of the MP3 file in the memory, each time playing it, or can i use a 'master' Sound instance ,that I can play multiple times simultaneously.(similarly I can use one 'enemy.jpg' bitmapdata, that I can then copy to the screen with copyPixels, and only having it in the memory just once )IE if i have 50 'Enemy' characters running around the game
View 1 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
Apr 16, 2011
I placed a movie clip instance inside a button, and I want this movie clip to play when the button is released. I'm using this code on the frame containing the button:
function playMovie(event:MouseEvent)
{
this.theButton.theMC.gotoAndPlay(3);
[code].....
View 2 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
Dec 20, 2010
var sound_[infotoload]:Sound = new Sound();
This doesn't work. I want sound_01 sound_02 sound_03 sound_04
View 1 Replies
Jan 17, 2007
The buttons of my menus are mc with instance names. I want to play a click sound on each of them on rollover.
View 8 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
May 24, 2011
I have an MC with a lot of frames on stage and it has sound clips attached to each frame.
I need to stop the sound being played when I move on to another frame on runtime, thus, I need to access the sound object which has no instance name. Right now the sounds overlap since none of them stops and after a while all we hear is jibba jabba.
View 1 Replies
Apr 7, 2011
When I open one of my cs3.fla's and save it as a cs5.fla and then export I'm getting the following output message.
'play' is not a valid instance name. Please enter an identifier that is not a reserved keyword or function.
This only happens when I export it for the first time after opening it (if I close that file down and open it again I get the same message)
I dont have any clips with the instance name 'play' or anything like that
View 4 Replies
Feb 8, 2009
configuring this instance movie to play when i click a button, here is my movie structure:
- root movie - container and some external .swf movie
The process is there will be button load at the end of root movie, and calling some external swf movie with number. all the swf will play in a container each swf movie(about 5 animation)
At the end of root movie there is also some loop animation that play at the end of root movie, while we can click the button also.
What i want to do is how can i play the loop movie, start from the middle when i click one of the button.
So what happen will be: - click button = external movie load and the instance name play from frame 100 and loop again.
View 3 Replies
Jul 31, 2011
I created a button on the stage and made it a movie clip and called it's instance name "play_btn" then i made a document class "main.as" and a second class "play button.as". How is to access the instance name in the play button.as file like this...
public class login_page extends MovieClip {
public function login_page() {
play_btn.addEventListener(MouseEvent.MOUSE_DOWN, onPlayDown);
} public function onPlayDown(evt:MouseEvent):void {
trace("Test");
}}
And then I want to call the function in the main.as.. but the general problem is that I want to access the instance name "play_btn" in the "playbutton.as" file. I tried to link it to the class but i get this error: 1120: Access of undefined property play_btn.
View 4 Replies
Apr 30, 2009
I have recently adopted an FLV from someone else. It is structured "unconventionally" at best. For this reason (and because I am not well-versed in AS3), I haven't been able to get a pause/play button to function properly. About the file, The project is a 6-7 minute demo for a new product complete with voiceover. You have to drill in 3 movie clips deep before you can get to much of the animation. There are gotoAndPlay functions at the end of each 3rd-level movie clip that refer to a frame on the 2nd level.
On the 2nd-level frame, there is a stop function which allows the next movie clip to play. Each movie clip contains a sound layer for voice over. About the play/pause button. The instance name is pauseBtn. The button code below is on the 1st frame of the main timeline. There is a keyframe on the second frame for another bit of code. The button itself is a 2-frame MC that spans the entire main timeline. The event.target.gotoAndStop() lines are working properly to change the look of the button.
My button scriptstop();
import flash.media.SoundMixer;
var pp:Boolean = true;
function ppState(event:MouseEvent) {
if(pp) {
stop();
[Code] .....
What happens when I test the movieThe animation plays without problem as long as the button is not clicked. I haven't been able to see a pattern in the chaos that occurs when the button is clicked.
Sometimes nothing happens.
Sometimes it stops the sound only.
Sometimes it resets to the beginning of the movie.
Sometimes it starts play random parts on top of what was already playing.
This error appears in the output pane.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at NameOfTheFile_fla::MainTimeline/chk()
View 8 Replies