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

    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 {
    //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.dispatchEvent(new Event (DragDropObject.PLACED));
                        } else {
                            if (
    _snapBack == true) {
                                //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