Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

check if the time is right inside canvas

New Here ,
Mar 13, 2018 Mar 13, 2018

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.

117
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2018 Mar 14, 2018
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines