However, when implementing js to transfer values to flash, there is a probability that flash can obtain the value. Sometimes it can be obtained, and sometimes it cannot be obtained. Later, it was discovered that it was actually because the flash corresponding to had not been loaded, and the method opened by ExternalInterface.addCallback() in the flash was started to be called in js, resulting in the flash not being obtained. Music will start playing when the time comes. At this time, of course, it cannot be played. In order to ensure that the value can be transferred normally, the value must be transferred after the flash is loaded. But how to judge? In fact, just use the PercentLoaded interface of flash's open js. The details are as follows:
Js code
var checkFlashLoaded = setInterval (function() {
if(flash.PercentLoaded =100) {
flash.setBGMusic("bkmusic.mp3");
clearInterval(checkFlashLoaded);
}
},10) ;
var checkFlashLoaded = setInterval(function() {
if(flash.PercentLoaded =100) {
flash.setBGMusic("bkmusic.mp3");
clearInterval(checkFlashLoaded);
}
},10);
You can know whether the flash loading is completed by judging whether PercentLoaded is 100%. If not, keep monitoring until it is completed. After success,
will pass the value again. , only then can the value transfer be guaranteed to be successful.