Hi I face some problem with my flash script. Here is my code
开发者_StackOverflow中文版onFrame (1) {
mySound = new Sound();
mySound.loadSound("http://www.mysite.com/spot_mixdown.mp3 ");
mySound.start(0, 0);
}
that play .mp3 file from my website at the first frame. It's work for me!
But when I update spot_mixdown.mp3 (change sound inside but use same filename) on my website and then reload webpage, a sound is not change.
How do I fix it? or another way to do.
Thank you.
Your browser is probably caching the mp3. You can prevent this by adding a unique sequence to the end of the URL for the mp3. (Also, I think you want to get rid of the space). Generally, either new Date().getTime()
or Math.random()
is sufficient.
mySound.loadSound(
"http://www.mysite.com/spot_mixdown.mp3?cachestopper=" +
new Date().getTIme());
The problem us that your browser has cached the mp3 file, and doesn't know that the content has changed.
To fix this (once), just clear your browser's cache manually.
If you want to reload every time, you can add a spurious attribute to your URL to fool it into reloading. For example:
mySound.loadSound("http://www.mysite.com/spot_mixdown.mp3?"+Math.random()*100000);
The bit after ".mp3" is ignored by the mysite.com server, but your browser will think you're asking for a different mp3 file every time.
精彩评论