alzami Posted June 11, 2014 Share Posted June 11, 2014 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 More sharing options...
justsomeguy Posted June 11, 2014 Share Posted June 11, 2014 Are you seeing any error messages on the Javascript console? Link to comment Share on other sites More sharing options...
alzami Posted June 11, 2014 Author Share Posted June 11, 2014 (edited) one error : f.isVisible is not a function ...only this one Edited June 11, 2014 by alzami Link to comment Share on other sites More sharing options...
justsomeguy Posted June 11, 2014 Share Posted June 11, 2014 That's not in the code you posted, where is that coming from? Link to comment Share on other sites More sharing options...
alzami Posted June 11, 2014 Author Share Posted June 11, 2014 edited my answer.pls check it out.i have been trying different things with the codes i have written after posting here.sorry if i confused you Link to comment Share on other sites More sharing options...
justsomeguy Posted June 11, 2014 Share Posted June 11, 2014 I still don't see where the code you posted in the first post is calling isVisible. That error is coming from other code. The error console will tell you exactly where it is coming from. Link to comment Share on other sites More sharing options...
alzami Posted June 11, 2014 Author Share Posted June 11, 2014 i use the same code i posted above and pressed F12 in firefox.which showing me this error...... Link to comment Share on other sites More sharing options...
davej Posted June 11, 2014 Share Posted June 11, 2014 So you are adding an OOP object constructor on top of this code... http://www.createjs.com/tutorials/Getting%20Started/ Link to comment Share on other sites More sharing options...
justsomeguy Posted June 11, 2014 Share Posted June 11, 2014 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 More sharing options...
alzami Posted June 11, 2014 Author Share Posted June 11, 2014 that's the easeljs.js file.i have used it in other codes.it works fine.it is confusing me...i have just started to learn easeljs.never used constructor with easeljs though Link to comment Share on other sites More sharing options...
justsomeguy Posted June 11, 2014 Share Posted June 11, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now