Home > Web Front-end > JS Tutorial > Solving the problem of stable value transfer between js and as_javascript skills

Solving the problem of stable value transfer between js and as_javascript skills

WBOY
Release: 2016-05-16 17:28:48
Original
1057 people have browsed it

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

Copy code The code is as follows:

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.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template