ActionScript 3.0 :: How To Close Sound Object

Jul 27, 2008

I'm using Flash CS3, running code in ActionScript 3. I use the Loader class to load a child SWF file, which then takes over the entire area on my website that is reserved for Flash. If the user decides to stop watching the SWF file before it is completed, he hits the "close" button within the child SWF, ultimately causing the Loader.unload() method to be executed. So far, so good, only the sound from the remaining portion of the SWF file keeps playing. According to the Flash Docs for the Loader.unload() method:

"As a best practice, before you unload a child SWF file, you should explicitly close any streams in the child SWF file's objects, such as LocalConnection, NetConnection, NetStream, and Sound objects. Otherwise, audio in the child SWF file might continue to play, even though the child SWF file was unloaded."

It then gives an example that assumes you already have access to the Sound object, so closing the Sound object is done by: mySound.close();

The only problem is that I have no idea how to access the Sound object when I use the Loader.load() method. I can't seem to find anything in the documentation that tells me how to find the Sound object after calling Loader.load(). As a temporary fix, I modified the target SWF file so that when the "close" button is hit, it calls the "stop()" function; however, this only stops the sound, it does not close the associated Sound object, and I presume it continues to lurk around in memory with nothing useful to do. (When the user hits the "close" button in the child SWF file, it creates a "bubbling" event so that the Loader class can call the Loader.unload() method on it.) I've attached code for your reference.

View 13 Replies


Similar Posts:


ActionScript 3.0 :: Open And Close A Sound Stream?

Jan 11, 2010

I am stumbling across this issue as I open and close a sound stream. This is the code I use, not sure if closing and opening a stream on the same function is a good idea.

[Code]...

View 4 Replies

ActionScript 2.0 :: Start A Sound When 2 Objects Are Close To Each Other?

Sep 18, 2006

Here is the code I've got so far:

Code:
campFireSound_mc.onEnterFrame = function(){
xdist = Math.round(this._x-fenris_mc._x);

[code]....

View 7 Replies

ActionScript 3.0 :: Using Hit Detection - Object Doesnt Get Very Close The The Second Object But The Game "thinks" It Does

Nov 20, 2010

i'm currently using hitTestObject and it kinda sucks, my object doesnt get very close the the second object but the game "thinks" it does. is there a better hit detection?

View 7 Replies

Object To Follow Mouse When Close?

May 18, 2009

I have this kind of menu structure design (see image attached), and the way It needs to work is when the mouse goes close to a topic it follows it and when the mouse is a certain distance away it springs back to its orginal place?

View 6 Replies

Flash :: Dynamically Create New Sound Objects Based On Raw WAV / DATA Or Other Sound Object?

Jan 31, 2012

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]...

View 1 Replies

Actionscript 3 :: Sound.extract Method Empties Sound Object Data

May 20, 2011

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?

View 3 Replies

ActionScript 2.0 :: F8 - Attach Sound Object To A Separate Mc To Control Independently From All Other Sound / Root Volumes

Mar 15, 2008

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]...

View 2 Replies

ActionScript 3.0 :: Close A Netstream In A Loader Object?

Jul 20, 2009

I'm working on my portfolio, and I'm having a bit of trouble. I'm loading a custom made video player SWF into my main SWF, and it works well so far, but the NETSTREAM doesn't close when I remove the child after I return to the main menu, and the audio keeps going.

View 1 Replies

Flash - Take Two Sound Objects And Combine Them Into One Sound Object

Nov 15, 2010

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 Replies

ActionScript 2.0 :: Streaming Sound Distorted - Sound Object?

Jun 14, 2004

I 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 Replies

ActionScript 3.0 :: Clear Shared Object When Close Flash Player?

Aug 9, 2011

Is there a way to clear shared object when I close Flash player.

stage.addEventListener(Event.UNLOAD, Close);
function Close(event:Event):void
{
mySO.clear();
}

View 1 Replies

ActionScript 2.0 :: Close Browser By Clicking On Close Button Embedded Swf?

Jul 27, 2009

i want to close browser by clicking on close button embedded swf. I have tried fscommand("quit"), but which is not working on browser.

View 9 Replies

ActionScript 2.0 :: Sound Object FMX AS 2.0?

Apr 26, 2010

tell me if there is something wrong with this? playbtn_mc is a button with that instance name.... The button is on the main timeline not in another mc, I tried _root.my_sound.start(); also. The mp3 name is correct and is in the same folder as the fla and swf

playbtn_mc.onRelease = function(){
var my_sound:Sound = new Sound();
my_sound.loadSound("backtoschool.mp3", true);
my_sound.start();
}

I've been to the kennybellew as2 tut but cant seem to get it working with onload?

View 1 Replies

Actionscript 3 :: Use Sound Object Methods On FLV?

Mar 22, 2010

I'm recording and playing back mic input using Flash Media Server, and even though it's just audio, we're saving the output as FLV. I'd like to get a waveform of the recorded audio. Ideally, since we already have a lot of saved/recorded audio, I'd like something that can take a loaded FLV and get the waveform, as opposed to generating it at record or playback time.

AS3 has the new Sound.extract() method that can be used for this (plenty of online tutorials), but it seems like it only works for MP3. Is there a way to use this method on FLV audio? Or is there another to extract a waveform from a FLV?

View 1 Replies

Actionscript 3 :: Know If A Sound Object Is Playing?

Jan 18, 2012

In AS3 i've created a code that load a sound and execute it in streaming.

var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
mySound.load(new URLRequest("surrender.mp3"));
myChannel = mySound.play();

Considering that the mp3 file is placed on the server, i need to trace if it's already begun or still receiving initial data from the server. Once it's effectively started i've to call a function that initialize some things.

how i can trace if a sound or channel object "is playing" ?

View 2 Replies

ActionScript 2.0 :: Sound Object And Preloader?

Jan 27, 2009

Has anyone got an angle on the interference that linkage can create when the "export in first frame" option is ticked? I am using attachSound and the sound object to load an mp3 but it is wreaking havoc with the preloader.If I uncheck the "export in first frame" box the sound does not seem to be instantiated. I believe that a way around this is to drag the sound onto the stage, but if you have 8 sounds for buttons for example, then you would have to create 8 sound layersMy preloader code is:

Code:
stop();
_root.preloaderGraphics._visible = false;

[code]....

View 9 Replies

ActionScript 3.0 :: Get Sound Object To Change?

Dec 8, 2010

I am feeding a player from xml, and I'm not able to get the track to change.

ActionScript Code:
private var _currentTrackNum:int;
public var playlistdata:ArrayCollection = new ArrayCollection();
public var locationarray:Array = new Array();

[code]....

The previous track function is basically the same. It does nothing, however. I can trace out _currentTrackNum and see that changing, but the song playing stays the same, even if i stop and start again, or build the stopping and starting into the function. BUT. I can change the value of currentTrackNum at the outset and it wil effect which song plays.. !?

I'm thinking maybe there is some kind of sound.unload function I need to try, but am quite confused as to why it doesn't work. The locationarray.length is coming out as 0 for some reason I don't fully understand, so I disabled that 'if' statement for incrementing track number but that didn't help..

View 3 Replies

ActionScript 3.0 :: Move An Object With Sound?

Jan 7, 2012

i'm creating an interactive experience and I need to move a bar on screen reacting to the volume of people sreaming at a microphone. Like a CLAP-O-METER... is this possible with ActionScript?

View 1 Replies

ActionScript 2.0 :: Preloader For Sound Object?

Nov 28, 2005

I have a movie with three songs using the following code in frame 2:

Code:
song1 = new Sound();
song1.attachSound("song01", "song001", 1);
song2 = new Sound();
song2.attachSound("song02", "song002", 1);

[code]....

In frame 1 i have the following preloader script:

Code:
this.onEnterFrame = function(){
tb = this.getBytesTotal();
lb = this.getBytesLoaded();

[code]....

and a text saying that the sound is loading. But when I play the movie i doesn't show the text.

View 4 Replies

ActionScript 2.0 :: Sound Volume Per Object?

Apr 5, 2006

I can't seem to figure out how I set the volume of a single sound object. Everytime I use setVolume on a sound, it is applied to *all* sound objects playing The code that I'm using :

Code:
music = new Sound();
music.attachSound("music");

[code].....

View 1 Replies

IDE :: Sound Object Parent Reference?

Jun 8, 2009

I'm creating a bunch of movieclips, associating a sound object with them, and then updating them with a progress bar, like so:

var theClip:MovieClip = new MovieClip;
theClip.track = new Sound;
[load sound from URL pseudocode here]
theClip.track.addEventListener (ProgressEvent.PROGRESS, onLoadProgress);
function onLoadProgress (erogressEvent):void {

How do I reference the movieClip the sound is a child of? e.target refers to the sound object; e.target.parent returns an error. And you can't assign properties to sound objects.

View 1 Replies

ActionScript 3.0 :: Sound Object Or SoundChannel For Various Sounds?

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

Professional :: Get The Full Duration Of A Sound Object?

May 5, 2010

I was wondering how I can get the full duration of a sound object.I know "sound.length" returns me the loaded length,but is there a way to get the full length so i don't have to wait until i loaded?

View 2 Replies

ActionScript 2.0 :: Sound Object > To Play While Streaming?

Sep 30, 2010

I had a question. So now I am streaming an mo3 file using the sound object (loadSound function) ...So the mp3 is loading (and I have a progress bar showing the percentage loaded) and while it is loading it is being played. Now, when the playhead (the location being played) reaches the end of whatever has been download, it goes to the beginning (repeats). I am looking for a way to make the sound pause once it reaches the end, and then wait until a reasonable amount has been downlaoded, so that it may continue playing again. I hope I was clear.

View 5 Replies

Professional :: Sound Button On Drag Object?

Oct 10, 2010

Stuck on this big time. Using as2. I have a draggeable record. I want a button on the record that when I hit it, it plays a sound. I've attached the source. I've tried a few different tests and I've figured out that the onpress action of the main mc itself I believe acts for the mc of the speaker. I want the record draggable but need to have the speaker activate if i hit it.[URL]..

View 1 Replies

Actionscript 3 :: Playing A Sound Object In Reverse ?

Feb 3, 2010

For a project I'm working on, it's necessary that I am able to play a sound object in reverse. How would I be able to do this in AS3?

View 1 Replies

Actionscript 3 :: Create Sound Object Dynamically?

Mar 19, 2011

How to create sound object dynamically in one movieClip.

Example

for(i=1;i<5;i++){var sound + i = new Sound();}

View 2 Replies

ActionScript 2.0 :: GetBytesTotal() Method Of The Sound Object?

Sep 13, 2008

What's the purpose of the getBytesTotal() method of the Sound object since it returns the same value as the getBytesLoaded() method? Note that I mean streaming mode here.

View 7 Replies

ActionScript 2.0 :: Control Object Visibility With Sound?

Nov 12, 2009

I need to make the object visible when the external mp3 reaches 8.2 seconds, what I�m doing wrong...?

ActionScript Code:
my_sound.loadSound("audio/sound_1.mp3", true);
var my_sound:Sound = new Sound();

[code].....

View 9 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved