UPDATE making the colorChange function global solves the problem
I am trying to change the color of the path when the button 'Red' is clicked using colorChange function .Regardless of my logic , the error says 'Function 'colorChange' is not defined' . The internal paper js functions like path() are working , but my function isn't .
<head>
<!-- Load the Paper.js library -->
<script type="text/javascript" src="js/paper.js"></script>
<!-- Load external PaperScript and associate it with myCanvas -->
<script type="text/paperscript" src="js/myScript.js" canvas="myCanvas"></script>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<button onClick='colorChange(id)' id='red'>Red</button> // Using it here
<canvas id="myCanvas" resize="true"></canvas>
</body>
Here's myScript.js for canvas ID='myCanvas' :
var myPath={};
var colorChange=function(id){ //function I defined doesn't work
myPath=new Path();
myPath.strokeColor=id;
}
function onMouseDown(event){ //this works
myPath=new Path();
myPath.add(event.point);
}