Problem with starting a Sound at a specified position (AS2)

你。 提交于 2019-12-12 18:10:00

问题


I have an issue with an Actionscript 2 piece of code. I'm trying to load a song and start playing it at the 50th second until the end.

var song:Sound = new Sound();
song.setVolume(100);
song.loadSound(songToPlay,true); // songToPlay is a valid path
song.start(50);

This loads and play the Sound, but at the begining and not at 50 seconds like I want. I also tried

song.start(50,1);

without success.

What am I doing wrong?


回答1:


In order to start a sound file at a specific time, you have to start it after it's finished loading (or at least loaded past that point).

Try something like this:

var song:Sound = new Sound();
song.setVolume(100);
song.onLoad = function(success:Boolean) 
{
   if (success) 
   {
      song.start(50);
   } 
};
song.loadSound(songToPlay,true);


来源:https://stackoverflow.com/questions/1217050/problem-with-starting-a-sound-at-a-specified-position-as2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!