我的问题:
我有一个Flash游戏。它有15个问题。每个回答正确的问题都会给你一枚硬币。游戏中有一项更新硬币和体验的功能:function updatePointsAndCoins_V2()
。
http://www.squlaworld.com/demo-english
我在包含CSS,HTML和JS文件的文件夹中创建了一个叠加层。有没有办法在function updatePointsAndCoins_V2()
发出value = 15
时加载这些文件?
function suggestedQuiz()
。
有没有办法在启动该功能时加载覆盖文件?这是我使用的重叠脚本:
(function(showOverlay) {
var triggerBttn = document.getElementById( 'trigger-overlay' ),
overlay = document.querySelector( 'div.overlay' ),
closeBttn = overlay.querySelector( 'button.overlay-close' );
transEndEventNames = {
'WebkitTransition': 'webkitTransitionEnd',
'MozTransition': 'transitionend',
'OTransition': 'oTransitionEnd',
'msTransition': 'MSTransitionEnd',
'transition': 'transitionend'
},
transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
support = { transitions : Modernizr.csstransitions };
function toggleOverlay() {
if( classie.has( overlay, 'open' ) ) {
var wrapperposition = document.getElementById('wrapperposition');
wrapperposition.style.display = 'none';
classie.remove( overlay, 'open' );
classie.add( overlay, 'close' );
var onEndTransitionFn = function( ev ) {
if( support.transitions ) {
if( ev.propertyName !== 'visibility' ) return;
this.removeEventListener( transEndEventName, onEndTransitionFn );
}
classie.remove( overlay, 'close' );
};
if( support.transitions ) {
overlay.addEventListener( transEndEventName, onEndTransitionFn );
}
else {
onEndTransitionFn();
}
}
else if( !classie.has( overlay, 'close' ) ) {
classie.add( overlay, 'open' );
var wrapperposition = document.getElementById('wrapperposition');
wrapperposition.style.display = 'block';
}
}
triggerBttn.addEventListener( 'click', toggleOverlay );
closeBttn.addEventListener( 'click', toggleOverlay );
})();
答案 0 :(得分:0)
在您的页面中,您需要定义Flash游戏试图调用的方法。在这种情况下,它是updatePointsAndCoins_V2方法。
因此,在您的页面中,您可以添加以下内容:
<!-- language: lang-js --> // ignore this line, it's for stackoverflow syntax highlighting
<script>
function updatePointsAndCoins_V2 (coins) {
console.log(coins); //look in the console to see what coins is
// With nothing to go on I'll assume it passes them as a number in the first parameter of the function
if (coins >= 15) {
showOverlay(); // You will need to define this function and the logic which shows your overlay.
}
}
</script>