At 10/6/12 04:29 PM, HoundByte wrote:
how do i fix this?
There are a few issues with your code.
hey im tring to access an object called "block" on my stage
Does this mean you place a Movieclip on the stage of Adobe Flash and gave it an instance name "block"? I will assume that for now.
and i put this inside a class that my player is using
as mentioned above, the player class should not handle its own hittest, because this requires knowledge of the other object you want to test against.
Do the test in your document class, which automatically has a property (variable) "block" that references the object you placed in Flash by hand.
While it makes no sense conceptually, this line is still troublesome:
var cube = stage.getChildByName("block");
First of all, read about what "stage" is. It's really important that you understand that it is not the thing you can drag and drop your MovieClips onto in Adobe Flash, which is also often called "the stage". You should not add things to ".stage"
Secondly, the name of an MC (or DisplayObject, for that matter) which is stored in the property ".name" has nothing to do with the instance name.
These 2 things can be misunderstood easily and will screw things up if that happens. Pay attention.