Author Topic: Improvements  (Read 14808 times)

  • Administrator
  • Sr. Member
  • *****
  • Posts: 407
    • View Profile
Re: Improvements
« Reply #105 on: June 20, 2020, 12:01:13 am »
I've done Ava voice synchronization for both scenes finally. Will share files most likely tomorrow.

I had it done for some time but it sometimes stopped working and took me hard time to figure it out.
The problem is a race condition with one user defined function controlling start of playing some segment and another function in onEnterFrame event checking sound play position and stopping at the end of segment. Normally two scripts are not executed simultaneously as it doesn't run multithread. But as it turned out, Sound.start() function doesn't take effect immediately, so when the sync function called by animation starts the sound again from the beginning of file, the onEnterFrame event function executed later sees the playback position still at the end of last segment and thus it calls Sound.stop() because it looks like the played segment is finished. So the solution it to add simple interlock to avoid stopping the sound in the same frame the sync start function is executed.
It worked sometimes anyway because there is no guaranteed order of scripts execution in Flash.