Not sure where the difference lies here, but I am trying to understand it. In this piece of code that is a public function of a MC with instances of other MCs in it, I cannot seem to access the instances except in a function within the public function (confused? so am I but here’s the code):
public function TitleFlight(stageX=800, stageY=800):void{
var dTimer1:Timer = new Timer(5);
x = -600;
y = stageY + 600;
gotoAndStop(100);
[COLOR=red]head.teeth.gotoAndStop(5);[/COLOR]
scaleX = 2.5;
scaleY = 2.5;
dTimer1.start();
dTimer1.addEventListener(TimerEvent.TIMER, SpinDude);
function SpinDude(e:TimerEvent):void{
rotation += 1;
[COLOR=lime]head.teeth.gotoAndStop(5);[/COLOR]
armL.rotation += Math.random()*2 + 1;
armR.rotation += Math.random()*2 + 1;
}
}
[COLOR=black]the line in green works fine (like the rotation calls below it), but if I try the same thing (as above in the red font) out side of the SpinDude function, I get this error:[/COLOR]
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Actors::TheDude/TitleFlight()
at Main/::TitlePage()
at Main$iinit()
Can anyone tell me why?