problem solved. please see comments. I can't answer my own question due to reputation points.
I'm trying to develop a simple flash game. I have a symbol and an AS3 class linked to this symbol called Splash (which represents intro screen of Game) and a StartButton symbol. StartButton symbol placed in Splash symbol using Flash IDE given instance name of 'button_start'.
In Splash.as I'm trying to access StartButton's ADDED_TO_STAGE event handler but i got null pointer exception. Here is code:
public function Splash() {
trace("splash const");
addEventListener(Event.ADDED_TO_STAGE, ats);
super();
}
public function ats(e:Event) {
trace("splash ats");
var i:int = 0;
for (i=0;i<numChildren;i++) {
if (getChildAt(i).name.search("button")) {
trace("bulundu");
buton = getChildAt(i) as MovieClip;
buton.addEventListener(Event.ADDED_TO_STAGE, butonats);
}
}
}
function butonats(e:Event) {
trace("buton ats");
}
Result:
splash const
splash ats
bulundu
TypeError: Error #1009: Boş nesne başvuru özelliğine veya yöntemine erişilemiyor.
at Splash/ats()
Doesn't ADDED_TO_STAGE run's when all children ready ? Where is wrong couldn't figure it out.
buton
objectvar buton:MovieClip;
– Eric Lavoieas
operator will return null: as operator documentation – Eric Lavoie