views:

24

answers:

1

Hello i'm trying to drag something, and on stopdrag it should start a function if certain requirements are fullfilled. My code looks like this.

if(e.target.dropTarget.parent == targetName || e.target.dropTarget.parent.parent.parent.getChildByName("cloud").getChildByName("itemPlacer").getChildAt(1) == targetName){

I got 2 questions, first, this works good when i drag and stopdrag correctly(the requirements in the if are fullfilled). but if the requirements are not fullfilled i get an error saying that the place i'm referring to cant be null. I know that the problem lies after the || part but dont know how to resolve it. 2nd, isnt there a shorter way of doing these checks? Atm i'm going through alot of parents and getchildats and was wondering if there was another way.

ty in advance.

+1  A: 
PatrickS
Description Resource Path Location Type1061: Call to a possibly undefined method getChildByName through a reference with static type flash.display:DisplayObject. Start.as /eindwerk MA1/src line 155 Flex Problem.i get this error when assigning the variables
vincent