0
votes
if (goblin.hitTestPoint(character.aMode.lance.x, character.aMode.lance.x, true))
{
trace("goblin been hit, please minus one life");
}

This is the code and the error is: 1119: Access of possibly undefined property aMode through a reference with static type player.

This is how I set my code

public static var character:player;
character = new player;
container.addChild(character);

character was dynamically added to container. In character there are four frames, the third frame contains a movieclip and it's called "aMode" in the instance name. Inside the movie clip, there is another movieclip called Lance, with the instance name of "lance".

In As2 I'm sure this would work.

I think the problem is that since aMode isn't on the first frame, character.aMode(should be in the first frame) in order for it to work.

or perhaps it's not added to the display list, but flash should automatically add it to the display list, right?

Sorry if it's too much.

Here is a picture for visual aid. enter image description here you can see that this aMode movievlip is in a different frame within the character movieclip (which was added dynamically)

1

1 Answers

1
votes

In As2 I'm sure this would work. In AS2 you would probably get an undefined and it would be ignored.

If your clip (player, in this case) is stopped on a frame that doesn't have a particular asset/property, you will be thrown that error. It is simply enough to do it like this:

if (character.aMode && goblin.hitTestPoint(character.aMode.lance.x, character.aMode.lance.x, true))...