In the game I’m making, I have a class called slowBall, which extends MovieClip.
The class works perfectly because when I put the movieclip on the stage and test the game everything goes fine. But the problem happens when I try to put the movieclip on the stage using actionscript. This is the code I put on the timeline:
var ball:slowBall = new slowBall();
And that’s when I get the error “TypeError: Error # 1009: Unable to access a property or a method of a reference to an object nil.
At slowBall / EFrame ()” (I actually get the error in Spanish, so I translated via Google to put it here).
After some working some time on figuring out what’s wrong with my class, I discovered that it has to do with the following piece of code:
if (this.hitTestObject(_root.rightPaddle) && xtimer==0) {
slowXSpeed*=-1;
xtimer++;
}
(I’ve created the following var before so I can use _root: private var _root:Object=MovieClip(root);)
The problem is with _root.rightPaddle (rightPaddle is a movieclip located in the main timeline).
As I said, I only get this error when I try to create the movieclip using AS, so the class itself is fine.
I need to know how to hittest that class and the movieclip rightPaddle (which is on the main timeline) without using the code I already have…
I have no idea… What can I do?
Thanks…
PS: I can post the full class if you want to, but I think it’s not necessary.