# Error #1009 Function with ceveral if statements won't run completely

**URL:** <https://forum.kirupa.com/t/error-1009-function-with-ceveral-if-statements-wont-run-completely/304330>\
**Category:** flash\
**Created:** [February 5, 2010, 1:59pm UTC](https://forum.kirupa.com/t/error-1009-function-with-ceveral-if-statements-wont-run-completely/304330 "2010-02-05T13:59:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mephisto102](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@mephisto102](https://forum.kirupa.com/u/mephisto102)\
**Post date:** [February 5, 2010, 1:59pm UTC](https://forum.kirupa.com/t/error-1009-function-with-ceveral-if-statements-wont-run-completely/304330/1 "2010-02-05T13:59:39Z")

</div>

Hello,

Starting to learn actionscript bit by bit. But im running into a problem i can’t solve atm. Does anyone have a clue what the solution is?

a fla CS3 document with labels and dropzones assignment. Place 10 labels on dropzones in de correct order.  
I’ve created a function to check if the labels are on the right dropzones. But the function _( private function controle ():void)_ runs only the first two if then else constructions. When proceeding to the third i get and error namely;

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at lijstcompleet/controle()  
at lijstcompleet/checkTarget()

the file DragDrop.as is the document class. Lijstcompleet.as is a seperate class. I did not post the class because of the length. This is the function causing the problem.

private function controle ():void  
{  
if(Vlabel1.hitTestObject(getChildByName(“inst\_dropzone0”)))  
{  
getChildByName(“inst\_thumbsup0”).alpha = 100;  
getChildByName(“inst\_thumbsdown0”).alpha = 0;  
trace (“controle juist1”)  
}  
else  
{  
getChildByName(“inst\_thumbsdown0”).alpha = 100;  
getChildByName(“inst\_thumbsup0”).alpha = 0;  
trace (“controle fout1”)  
}  
if(Vlabel2.hitTestObject(getChildByName(“inst\_dropzone1”)))  
{  
getChildByName(“inst\_thumbsup1”).alpha = 100;  
getChildByName(“inst\_thumbsdown1”).alpha = 0;  
trace (“controle juist2”)  
}  
else  
{  
getChildByName(“inst\_thumbsdown1”).alpha = 100;  
getChildByName(“inst\_thumbsup1”).alpha = 0;  
trace (“controle fout2”)  
}  
if(Vlabel3.hitTestObject(getChildByName(“inst\_dropzone2”)))  
{  
getChildByName(“inst\_thumbsup2”).alpha = 100;  
getChildByName(“inst\_thumbsdown2”).alpha = 0;  
trace (“controle juist3”)  
}  
else  
{  
getChildByName(“inst\_thumbsdown2”).alpha = 100;  
getChildByName(“inst\_thumbsup2”).alpha = 0;  
trace (“controle fout3”)  
}  
if(Vlabel4.hitTestObject(getChildByName(“inst\_dropzone3”)))  
{  
getChildByName(“inst\_thumbsup3”).alpha = 100;  
getChildByName(“inst\_thumbsdown3”).alpha = 0;  
trace (“controle juist4”)  
}  
else  
{  
getChildByName(“inst\_thumbsdown3”).alpha = 100;  
getChildByName(“inst\_thumbsup3”).alpha = 0;  
trace (“controle fout4”)  
}  
}

For more info PM me or see the attached documents. Help would be much appreciated. \* i know some things could be done with less code 🙂

kind regards mephisto102
