Skip to main content
Participant
March 13, 2018
Question

check if the time is right inside canvas

  • March 13, 2018
  • 1 reply
  • 138 views

Hi guys, I'm trying to check if the time is right to play mouseover animation for certain element. I placed a variable on the 1st frame of the timeline called "this.time_is_up = false;" and in the 88th frame "this.time_is_up = true;"

Outside the canvas element I have the following code:

<script>

var canvas, stage, exportRoot, bgExit;

function init() {

canvas = document.getElementById("canvas");

bgExit = document.getElementById('background_exit');

images = images||{};

addListeners();

var loader = new createjs.LoadQueue(false);

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(evt) {

exportRoot = new lib._XXX_BANNER_XXX_306X230_NL_Promotor();

stage = new createjs.Stage(canvas);

stage.addChild(exportRoot);

stage.update();

stage.enableMouseOver();

createjs.Ticker.setFPS(lib.properties.fps);

createjs.Ticker.addEventListener("tick", stage);

document.getElementsByTagName('canvas')[0].addEventListener( 'mouseover', function() {

  exportRoot.mcHolder.children[0].mcButton.gotoAndPlay('over');

});

In the last bit of code, I need to put an if statement, if (time_is_up == true;) to goAndPlay certain animation. But the variable time_is_up is not visible from outside HTML file. Please help me to get to it.

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    March 14, 2018

    exportRoot.time_is_up is the correct reference.  but it will be undefined until the code in your 1st frame executes.