removing a child from inside a behavior class?
A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: removing a child from inside a behavior class?

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    6

    removing a child from inside a behavior class?

    I'm having trouble removing drag and drop MovieClips when they are not placed in the right spot. In the code below I have it so if the drag and drop movieclip is not placed on the target, it removes itself. I tried this with parent.removeChild(this); and this.parent.removeChild(this); and both give me this error "TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at DragDropObject/onUp()"

    PHP Code:
    private function onUp(e:MouseEvent):void {
                
    this.stopDrag();
                
    this.removeEventListener(MouseEvent.MOUSE_OUTonUp);
                
                for(var 
    n:int=0n<_target.lengthn++){
                    
    //only continue if a target has been set
                    
                    //if (_target != null){
                        
    trace("hey " this.hitTestObject(_target[n]));
                        
                        
                        if ((
    this.hitTestObject(_target[n]) == true) && (e.type != MouseEvent.MOUSE_OUT)) { 
                            
    trace("hey again");
                            
    this._target[n].x;
                            
    this._target[n].y;
                            
    this.dispatchEvent(new Event (DragDropObject.PLACED));
                            break;
                            
                        } else {
                            if (
    _snapBack == true) {
                                
                                
    parent.removeChild(this);
                                
    //this.parent.removeChild(this);
                                //this.x = startX;
                                //this.y = startY;
                                
    this.dispatchEvent(new Event (DragDropObject.SNAPPED));
                            }
                        
    //}
                        
                    
    }
                    
                }
            }
            
            
        } 
    Last edited by Kennedy90; 04-23-2012 at 01:45 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com