Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Prototype

  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    37
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Prototype

    Here's my code (Not working):

    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();
       }
    }

    Not sure why this is not working but I would like to call the Circle() and Square() which is in the draw function.
    Is this even possible??
    I'm going crazy trying to figure this out!!

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,215
    Thanks
    12
    Thanked 338 Times in 334 Posts
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •