Collision detect not working
I have created a Class in code called Battery and am adding it inside a function named 'Clone'. Battery is derived from a base class with a filename of Components.as. Here's where I am adding battery inside a function named 'clone':
var ComponentRef:Class = getDefinitionByName("Battery") as Class;
var instance:object = new ComponentRef();
addChild(DisplayObject(instance));
instance.x = 500;
instance.y = 300;
instance.compName = "Battery";
instance.amperage = 20;
instance.partNumber = "BA12345";
I also have a movie clip with an instance name of 'negativeProbe' that I add an event listener to:
negativeProbe.addEventListener(Event.ENTER_FRAME, detectedColl);
this brings me to the detectedColl function where I am trying to do the collision detection:
var battery:Battery = new Battery();
if (battery.hitTestObject(negativeProbe)) {
trace("Collision!!!");
Trace never registers a hit. I don't get an error, but no hit is ever registered. What am I doing wrong here?
