Image

Imageasmor wrote in Imagejavascript

UPDATE: I figured out the problem. It's something I feel stupid about. The character object had some functions with the same name as the AGEElement, which is fine. The problem is, I was defining both of them with functions called _functionName(). So AGEElement was referring to _show() and so was Character.

Hey everyone, just joined. I've been programming Javascript for a long time now and I'd like to think I'm pretty good with it. That said, my skills have more or less stagnated over the past couple years and all the wonderful innovations it's brought with it.

I'm a CS major in college and Java is their intro language of choice, so I've been learning that and have actually grown rather fond of it. It's really made me see some of the deficiencies of Javascript. That said, it's also influenced how I program Javascript, and I'm trying to be more object oriented and less procedural.

I whipped up something last night I've always wanted to do, an object for creating and absolutely positioning divs with no mess. It came out amazingly quickly and worked exactly as I'd hoped. With my vanity and love of TLAs, I called it AGE (Asmor's Graphics Engine), and the object is an AGEElement().

My problem comes in when I tried to implement it. I've taken on a project to try and make a combat tracker for D&D in Javascript. I've created another object, Character, which among other things has two AGEEelements: A box, which is always displayed, and a menu. When I try to add functions to work with those, it says that "this.box" has no properties. I have no idea what's happening or what's going wrong. I'm repeating code that's worked fine in isolation ver batim, but it's not working as part of this object. The specific line of code is:

	this.box=new AGEElement()


The AGEElement constructor just sets up the basic stuff, creating the div, id, and having the methods it needs to manipulate it. There's too much code to post here, so I'll provide appropriate links:

This is the HTML file I'm using to test this.
http://www.asmor.com/misc/CombatTracker/combattracker.html

This is just where I'm going to be storing character information. Eventually I'll have a method to generate code that's copied and pasted into this file.
http://www.asmor.com/misc/CombatTracker/defaults.js

AGE itself. Verified to work in isolation.
http://www.asmor.com/misc/CombatTracker/scripts/AGE.js

AGE supports wrappers that allow code to be inserted above and below the content of a div. This object automates the generation of those wrappers for making rounded, colored boxes. Verified to work with AGE.
http://www.asmor.com/misc/CombatTracker/images/boxes/boxes.js

The object that's causing the problem: Character
http://www.asmor.com/misc/CombatTracker/scripts/characters.js

For demonstration, a file using the AGE.js and boxes.js to show that they're working and proper implementation.
http://www.asmor.com/misc/CombatTracker/AGEtest.html