Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8823445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:21:27+00:00 2026-06-14T06:21:27+00:00

I’m trying to make a somewhat basic app using Canvas and Javascript for a

  • 0

I’m trying to make a somewhat basic app using Canvas and Javascript for a Windows 8 Application I’m making. Upon compiling the code in Visual Studio 2012 for windows 8 Apps I get the following message

0x800a1391 – JavaScript runtime error: ‘app’ is undefined

What Have I done wrong and what code do I use to fix the issue?

HTML

    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Untitled</title>

    <!-- WinJS references -->
    <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
    <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
    <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>

    <!-- references -->
    <link href="/css/default.css" rel="stylesheet" />
    <script src="/js/default.js"></script>
    <!-- CreateJS -->
    <script src="js/createJS/easeljs-0.5.0.min.js" type="text/javascript"></script>
    <script src="js/createJS/preloadjs-0.2.0.min.js" type="text/javascript"></script>
</head>
<body>
    <canvas id="gameCanvas"></canvas>
</body>
</html>

JS

var canvas, content, stage;
var bgimage, b1Image, p2Image, ammoImage, p1Lives, p2Lives, title, endGameImage;
var bgbitmap, p1bitmap, p2bitmap, ammoBitmap;
var preload;

// Scale Factor
var SCALE_X = window.innerWidth / 800;
var SCALE_Y = window.innerHeight / 480;
var MARGIN = 25;
var GROUND_Y = 390 * SCALE_Y;


function initialize() {
    canvas = document.getElementById("gameCanvas");
    canvas.width = window.innWidth
    canvas.height = window.innerHeight;
    context = canvas.getContext("2d");

    function prepareGame() {
        bgimage = preload.getResult("screenImage").result;
        bgbitmap = new Bitmap(bgimage);
        bgbitmap.scaleX = SCALE_X
        bgbitmap.scaleY = SCALE_Y
        stage.addChild(bgBitmap);

        stage.update();
    }

    //PreloadJS
    preload = new PreloadJS();
    preload.onComplete = prepareGame;
    var manifest = [
    { id: "screenImage", src: "images/Backgrounds/gameplay_screen.png" },
    { id: "redImage", src: "images/Catapults/Red/redIdle/redIdle.png" },
{ id: "blueImage", src: "images/Catapluts/Blue/blueIdle/blueIdle.png" },
{ id: "ammoImage", src: "images/Ammo/rock_ammo.png" },
{ id: "winImage", src: "images/Backgrounds/victory.png" },
{ id: "loseImage", src: "images/Backgrounds/defeat.png"  },
{ id: "blueFire", src: "images/Catapults/Blue/blueFire/blueCatapult_fire.png" },
{ id: "redFire", src: "images/catapults/Red/redFire/redCatapult_fire.png" }
];
preload.loadManifest(manifest);

stage = new Stage(canvas);
}

function gameLoop() {
    update();
    draw();
}

function update() {

}

function draw() {

}

app.oncheckpoint = function  (args) { 
    document.addEventListener("DOMContentLoaded", initialize, false);
    app.start();
};

Also on a side note I’m using CreateJS if that means anything

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:21:28+00:00Added an answer on June 14, 2026 at 6:21 am

    app isn’t a global so would indeed be undefined in the context you show above. It’s defined in a module (anonymous function) in default.js:

    (function () {
        "use strict";
    
        WinJS.Binding.optimizeBindingReferences = true;
    
        var app = WinJS.Application;
    

    That said, what are you trying to do in this bit of code? oncheckpoint would include code to persist state upon the suspension of your application; adding an event listener and calling start doesn’t really makes sense in that context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.