在 GWD 中为 HTML5 游戏构建容器,该游戏在展开的横幅广告中播放,并且无法确定在单击退出按钮时如何停止游戏脚本。例如,即使横幅处于未展开/关闭状态,声音也会继续在后台播放。
请帮忙!我更像是一名设计师而不是编码员,并且花了很多时间尝试不同的解决方案......我确信这是一个明显、简单的解决方案,但我只是看不到它。
先感谢您。
以下是相关代码:
<script>
function init() {
canvas = document.getElementById("canvas");
images = images || {};
var loader = new createjs.LoadQueue(false);
createjs.Sound.alternateExtensions = ["mp3"];
loader.installPlugin(createjs.Sound);
loader.addEventListener("fileload", handleFileLoad);
loader.addEventListener("complete", handleComplete);
loader.loadManifest(lib.properties.manifest);
}
function handleFileLoad(evt) {
if (evt.item.type == "image") {
images[evt.item.id] = evt.result;
}
}
function handleComplete() {
exportRoot = new lib.PPD_CDW_HyperWiper();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
stage.update();
createjs.Ticker.setFPS(lib.properties.fps);
createjs.Ticker.addEventListener("tick", stage);
}
</script>
<script type="text/javascript" id="gwd-init-code">
(function() {
document.body.style.opacity = "0";
var gwdAd = document.getElementById('gwd-ad');
/**
* Handles the DOMContentLoaded event. The DOMContentLoaded event is
* fired when the document has been completely loaded and parsed.
*/
function handleDomContentLoaded(event) {
// This is a good place to show a loading or branding image while
// the ad loads.
document.getElementById('loading').style.display = 'block';
}
/**
* Handles the WebComponentsReady event. This event is fired when all
* custom elements have been registered and upgraded.
*/
function handleWebComponentsReady(event) {
document.body.style.opacity = "";
// Start the Ad lifecycle.
setTimeout(function() {
gwdAd.initAd();
}, 0);
}
/**
* Handles the event that is dispatched after the Ad has been
* initialized and before the default page of the Ad is shown.
*/
function handleAdInitialized(event) {
// This marks the end of the polite load phase of the Ad. If a
// loading image was shown to the user, this is a good place to
// remove it.
document.getElementById('loading').style.display = 'none';
}
window.addEventListener('DOMContentLoaded',
handleDomContentLoaded, false);
window.addEventListener('WebComponentsReady',
handleWebComponentsReady, false);
window.addEventListener('adinitialized',
handleAdInitialized, false);
})();
</script>
这是我认为我需要的代码将去的地方:
gwd.handleClose_buttonAction = function() {
// GWD Predefined Function
gwd.actions.gwdDoubleclick.goToPage('gwd-ad', 'banner-page');
};