Hi,
I’m fairly new to Flash and actionscript, and it seems I haven’t fully understood how the stage should be referenced when you start moving down in the object hierarchy.
Hopefully someone here can help me shed a light on what I’m doing wrong.
In this particular example, I have two classes - Main.as and Engine.as, both extending MovieClip. In Main.as, I instanciate Engine and pass along a reference to main stage:
gameEngine = new Engine( this.stage );
This appears to work all fine and dandy, in Engine I do the following:
- In the constructor, this.stageRoot is set to the stage reference that is passed along
- The real problem seems to come when I try to do the following:
this.stageRoot.addEventListener( MouseEvent.MOUSE_MOVE, mouseMoveHandler );
When I try to trace the event from the mouseMoveHandler function, I get the event properties. However, if I try to reference the properties, i.e. event.localY or stageY, I just get the following error:
Engine.as:60: 1119: Access of possibly undefined property localY through a reference with static type flash.events:Event.
I don’t understand why this happens, but it’s obvious that I’m doing something wrong. Thanks in advance for any and all help!