0

Errors on google chrome

I do not understand these errors as I've never come across them. If anyone could be of assistance, that would greatly be appreciated. The code is supposed to result in a circle formed for a key pressed at random positions while shrinking in size until it is removed from the page. The code works on Firefox Developer Edition however I still get only the deprecation error. I used the paper.js library.

Html

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

    <script type="text/javascript"
            src="assets/js/lib/paper-full.js">
    </script>

    <link   rel="stylesheet"
            href="assets/css/circles.css">

    <script type="text/paperscript"
            canvas="myCanvas"
            src="assets/js/circles.js">
    </script>

  </head>
  <body>
    <canvas id="myCanvas" resize></canvas>
  </body>
</html>

CSS

canvas{
  width: 100%;
  background-color: grey;
  height: 100%;
}

html, body{
  margin: 0%;
  width: 100%;
  height: 100%;
}

Javascript

var circles = [];

function onKeyDown(event){
  var maxPoint = new Point(view.size.width, view.size.height);
  var randomPoint = Point.random();
  var point = maxPoint * randomPoint;

  circles.push(new Path.Circle({
    center: point,
    radius: 500,
    fillColor: 'violet'
  }));
}

function onFrame(event){
  for(var i=0; i<circles.length; i++){
    circles[i].fillColor.hue += 1;
    circles[i].scale(.9);
  }
}
Romie
  • 1
  • 3
  • 1
    Possible duplicate of [XMLHttpRequest cannot load file. Cross origin requests are only supported for HTTP](https://stackoverflow.com/questions/20041656/xmlhttprequest-cannot-load-file-cross-origin-requests-are-only-supported-for-ht) – Josh Beam Oct 06 '17 at 18:20
  • 1
    You should post your code as text, so it's easier for us to review. Anyway, you're getting that error because you're working with local files, which aren't allowed to use AJAX (so it's like trying to access another domain, which is forbidden). Try to setup a simple server so you're able to make AJAX calls – Piyin Oct 06 '17 at 18:58
  • @Piyin I am a complete beginner to coding and I have not yet learned about setting up servers. However in the online courses via Udemy I'm taking, I will be learning node.js pretty soon. To my understanding, I should be able to create servers with node correct? Any resources you could point me to, to learn more about what I need to know would be cool. Thank you. – Romie Oct 06 '17 at 20:47
  • Correct, Node.js has modules to allow you to deploy an HTTP server. There are also builtin stacks that are quite used, one of which is XAMPP (Cross-platform Apache, MariaDB, PHP and Perl server). I like Codecademy, but besides it the best resource is the internet (hehe). Start small with lame tutorials but understand everything you're doing before moving on, so you get strong basis – Piyin Oct 06 '17 at 22:07

0 Answers0