Ken Rogers
08-02-2008, 03:36 AM
I have created a program with an "Aircraft" class which has the child "Panel". Panel seems unable to access the variables of its' parent. I get the following error when I run my program:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Panel$iinit()
at DataTag/::showPanel()
Here is my code:
package
{
import flash.display.*;
import flash.events.*;
import flash.text.TextField;
public class Panel extends MovieClip
{
var needle:Needle = new Needle();
public function Panel()
{
enterButton.addEventListener(MouseEvent.CLICK, closePanel);
addChild(needle);
needle.rotation = MovieClip(this.parent).heading;
}
function closePanel(event:MouseEvent):void
{
this.parent.removeChild(this);
}
}
}
How can Panel access the variables of its' parent?
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Panel$iinit()
at DataTag/::showPanel()
Here is my code:
package
{
import flash.display.*;
import flash.events.*;
import flash.text.TextField;
public class Panel extends MovieClip
{
var needle:Needle = new Needle();
public function Panel()
{
enterButton.addEventListener(MouseEvent.CLICK, closePanel);
addChild(needle);
needle.rotation = MovieClip(this.parent).heading;
}
function closePanel(event:MouseEvent):void
{
this.parent.removeChild(this);
}
}
}
How can Panel access the variables of its' parent?