Groups | Blog | Home
all groups > flash actionscript > june 2006 >

flash actionscript : How to stop a sound from loading ? my_sound.unload or something ?



tralfaz
6/8/2006 8:24:55 PM
[quoted text, click to view]

Yeah, I remember someone posted that solution a long time ago. It seems if you load a file with the same name the cache doesn't
know any better and adjusts the download size to the smaller one. Maybe it's a good way to do it! Could it be a way to remove an
mp3 from someone's cache after it plays? hmmmm Will have to do more testing.

tralfaz

adrianTNT
6/8/2006 10:59:27 PM
I want the sound to stop loading when I press the stop button, I have:

var my_sound:Sound = new Sound(_root);
my_sound.onLoad = function() {
my_sound.start();
};
preload_btn.onRelease = function() {
my_sound.loadSound("some_sound.mp3", false);
};
stop_btn.onRelease = function() {
my_sound.stop();
};

Say I click the "load" button, the sound starts loading, when I press the
"stop" button the sound should stop playing but I also want it to stop loading,
the sound keeps loading from given URL, it loads in background and making
network traffic. I can only fix this by giving my sound an empty sound file to
load, but it must be some other way, right? Something like my_sound.unload ?

Thank you.
Adrian.
kglad
6/9/2006 12:58:31 AM
use:



_root.createEmptyMovieClip("holderMC",depthVar); // define depthVar
s=new Sound(holderMC);
// do whatever with your sound, but to stop dl'g use:

adrianTNT
6/9/2006 1:06:53 AM
So I guess this means there isn't an easy way like my_sound.unload.
I think what you said should work fine by looking at your posts count (17197),
so you are not a beginner :)
Before I got your reply I found another solution, I created an empty file
nosound.mp3 and each time I click the stop button I tell my_sound to load that
empty sound instead the sound is currently downloading. I needed this for the
sounds player at http://www.FFILES.com

Thank you.
kglad
6/9/2006 1:22:24 AM
adrianTNT
6/9/2006 1:29:35 AM
[q][i]Originally posted by: [b][b]kglad[/b][/b][/i]
you're welcome. with your solution loading another mp3, are you sure it stops
the download of the first mp3?[/q]
Yes, it seems to work fine, it loads another sound in same sound (my_sound)
and it seems to replace loaded progress with the empty sound I gave and stops
previous loading.
I look at traffic icons on task bar and I see that there is no network traffic
after I click "stop" before this I could see continuous traffic while sound was
loading in background.


tralfaz
6/9/2006 2:01:24 AM
[quoted text, click to view]

Seems like I remember that it worked before because it was in a different folder on the server but I have to check it again, it's
been a long time.
tralfaz

kglad
6/9/2006 5:27:14 AM
i don't think it would work that way tralfaz. probably if the empty/dummy file
had the same name as a previously cached file, the attempt to force a 2nd
download (and overwrite the first) would result in the file being retrieved
from the cache and not downloaded (and not overwritten).
adrianTNT
6/9/2006 10:44:39 AM
As I said problem is solved now, seems to work fine, but since you talked about
cache... I looked into my temporary internet files and kept refreshing the
folder to see when the mp3 appears there, the large sound that is being loaded
doesn't appear there if I clicked the stop button before it was completely
loaded, then I clicked the stop button the my empty sound appears in temporary
internet files (nosound.mp3). If I clicked stop and then clicked the load
button again the large sound starts from zero (it has a preloaded so I can see
this).
kglad
6/9/2006 1:14:27 PM
tralfaz and i are discussing a possible fix for preventing the caching of mp3
(and possibly swf) files which would be a great file-protection benefit to
flash programmers.

for an mp3 to be protected you would need to append a large amount (for
broadband users) of data to the end to prevent complete download while
streaming through the part you wanted the user to hear. it's doable though.

for a swf you would also need to add a large amount of data to prevent
complete download while the swf is streaming and you would need to close the
browser window before the swf completes download. for linear timeline based
swfs that's doable.
adrianTNT
6/9/2006 10:10:52 PM
[q][i]Originally posted by: [b][b]kglad[/b][/b][/i]
tralfaz and i are discussing a possible fix for preventing the caching of mp3
(and possibly swf) files which would be a great file-protection benefit to
flash programmers...[/q]
That would be nice :)

AddThis Social Bookmark Button