Recently, the function of playing music in flash is implemented, which involves the interaction between js and as, because the function of dynamically changing music files must be implemented. However, when Javascript is used to transmit values to flash, there is a probability that flash will obtain the values, sometimes it can be obtained, and sometimes it cannot be obtained. Later, it was discovered that it was actually because of <object...> </object> the corresponding flash is not loaded. In js, The ExternalInterface in flash is called. addCallback () is enabled, so that when flash has not obtained the value, it starts to play music. At this time, of course, it cannot play. To ensure normal value transfer, the value must be passed only after flash is loaded. But how can this problem be determined? In fact, you only need to use flash open js interface PercentLoaded. The details are as follows:
Js Code
Var checkFlashLoaded = setInterval (function (){
If (flash. PercentLoaded = 100 ){
Flash. setBGMusic ("bkmusicloud ");
ClearInterval (checkFlashLoaded );
}
}, 10 );
Var checkFlashLoaded = setInterval (function (){
If (flash. PercentLoaded = 100 ){
Flash. setBGMusic ("bkmusicloud ");
ClearInterval (checkFlashLoaded );
}
}, 10 );
You can determine whether the flash load is complete by checking whether the PercentLoaded is 100%. If not, you can listen until the flash load is complete.
Pass the value again to ensure that the value is successfully transferred.
By bilipan