#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2010
    Posts
    46
    Rep Power
    5

    Prototype?? (Calling Methods)


    Here's my code:

    Code:
    var c=document.getElementById("myCanvas");
    var ctx=c.getContext("2d");
    
    
    var Shape = function(){}
    
    Shape.prototype.Circle = function(){
    	// Some code here
    };
    
    Shape.prototype.Square = function(){
    	// Some code here
    };
    
    
    MainMenu.prototype = new Shape();
    
    var MainMenu = function(ctx){
       this.draw{
    	this.Circle();
    	this.Square();
       }
    }

    What I want to do is to call the Circle() and Square() function inside my draw() function. But it doesn't work.
    Is this even possible??
    I'm going crazy trying to figure this out!!
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,124
    Rep Power
    4304
    Check your browser's error console for messages. "this.draw{" looks like a syntax error to me.

    P.S. The "Prototype" category refers to the Prototype framework, not the prototype aspects of the core language.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).

IMN logo majestic logo threadwatch logo seochat tools logo