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

  • Home
  • SEARCH
  • 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 8983555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:52:09+00:00 2026-06-15T20:52:09+00:00

I have the following function, which I’m using to load images from the hidden

  • 0

I have the following function, which I’m using to load images from the hidden section in my HTML into a JavaScript array:

window.onload = function(){
console.log("src " + document.getElementById("building").src);
    var sources = {};
        sources[0] = document.getElementById("building").src,
        sources[1] = document.getElementById("chair").src,
        //sources[2] = document.getElementById("drink").src

    loadImages(sources, drawImage);
};

Once the images have been loaded into the JS array, I call the ‘loadImages’ function:

function loadImages(sources, callback){
    var imagesDir = "";
    var images = {};
    var loadedImages = 0;
    var numImages = 0;

    console.log("length " + sources.length);
    for (var src in sources){
        numImages++;
    }
    console.log("Num Images " + numImages);

    var index=0;
    console.log("length " + sources.length);
    for (index=0;index < numImages ;index++){
        console.log(index);
        images[index] = new Image();
        images[index].src = imagesDir + sources[index];
        console.log("Adding " + sources[index]);
        callback(images[index]);
    }

    stage.add(imagesLayer); // should only be added once!!
}

which, in turn, calls the drawImage() method:

function drawImage(imageObj) {
    //var layer = new Kinetic.Layer();

    var canvasImage = new Kinetic.Image({
      image: imageObj,
      width: 50,
      height: 50,
      // puts the image in teh middle of the canvas
      x: stage.getWidth() / 2 - 50 / 2,
      y: stage.getHeight() / 2 - 50 / 2,
      draggable: true
    });

    // add cursor styling
    canvasImage.on('mouseover', function() {
      document.body.style.cursor = 'pointer';
    });
    canvasImage.on('mouseout', function() {
      document.body.style.cursor = 'default';
    });

    imagesLayer.add(canvasImage);
  }

This method draws the images to the centre of the canvas, and sets their ‘draggable’ property to true, so that they can be dragged and dropped around the canvas.

The JavaScript is all in the of my page, and in the I have a hidden section, where all of the images I want to draw to canvas are being loaded first. I’ve done this because it makes the images load and display in the browser much more quickly than if you load them directly from the source into the JavaScript.

The images are loaded with the following HTML:

<img id="building" src="images/assets/building.png" alt="Asset" />
<img id="chair" src="images/assets/chair.gif" alt="Asset" />
<img id="drink" src="images/assets/drink.gif" alt="Asset" />
<img id="food" src = "images/assets/food.gif" alt="Asset"/>

and I am loading around 40 or so images into the HTML

Currently I have this drawing two images to the canvas, “building” and “chair”, but for some reason, when I uncomment the line sources[2] = document.getElementById("drink").src to draw the third image to the canvas, and view the page in the browser, my canvas doesn’t display on the screen, and I get a console error that says,

uncaught exception: [Exception… “Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMCanvasRenderingContext2D.drawImage]” nsresult: “0x80040111 (NS_ERROR_NOT_AVAILABLE)” location: “JS frame :: http://www.html5canvastutorials.com/libraries/kinetic-v4.1.2.js :: :: line 4222″ data: no]

I am using the Kinetic.js library (http://kineticjs.com/), and it appears to me as if this error is in the library…

Does anyone know if this is the case? Or is there something that I’m doing wrong in my code that’s causing this error to occur?

  • 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-15T20:52:10+00:00Added an answer on June 15, 2026 at 8:52 pm

    It’s not an error in the library, it’s an error with that image. Either it’s getting the wrong src property or that image doesn’t exist at that location. Make sure you’ve got the url, filetype/name correct.

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

Sidebar

Related Questions

I have the following function which pulls in a Javascript block via AJAX from
I have the following function which creates a std::vector of iterators into another container:
All, I have the following array and function, which will create a multidimensional array
I have the following javascript function which i call on the submit button click....
I have the following function which is supposed to read a .html file and
Suppose I have the following function, which retrieves data from a server in the
I have the following javascript function which creates a new row with different cells
I have created the following function which prints a calendar with day starting from
I have the following function which takes a tiff stored as blob from an
I have the following function which works fine. function ($objects, $items = array()) {

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.