Jump to content

draw a red ball on canvas using constructor function in easeljs


alzami

Recommended Posts

here i am trying to create a red ball which is an instance of simpleBall constructor.but the code i've written is not drawing anything on the canvas.i am not sure what is wrong in my code.please help me out!!!

<html><head><script src="easeljs.js"></script></head><body><canvas id="mycanvas" width="1000" height="500" style="border:1px solid black;"></canvas><script>function makeit(){function simpleBall(color,radius){  this.color=color;  this.radius=radius;  this.initialize();  this.x;  this.y;}simpleBall.prototype.initialize=function(){  this.s=this.getGraphics();   }  simpleBall.prototype.getGraphics=function(){  var s=new createjs.Shape();    s.graphics.beginFill(this.color).drawCircle(0,0,this.radius);  return s;  }var canvas=document.getElementById("mycanvas");var stage=new createjs.Stage(canvas);var ball=new simpleBall("red",10);ball.x=100;ball.y=100;stage.addChild(ball);stage.update();}window.onload=makeit;</script>
Link to comment
Share on other sites

The error message should include a filename and line number pointing to the line where f.isVisible is used and creating an error. Your code does not include "f.isVisible" anywhere, so obviously that error is not coming from the code you posted. I assume it's coming from the file you include at the top of your code, possibly because you aren't using it correctly.

Link to comment
Share on other sites

That's what I'm saying, you're probably using it wrong and it's causing an error in that file. If you trace that error back to see where it is going wrong then maybe you can figure out why you're not using it correctly. Follow the errors.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...