A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: WHY am I getting undefined as a _droptarget?

  1. #1
    Retired SCORM Guru PAlexC's Avatar
    Join Date
    Nov 2000
    Location
    NJ
    Posts
    1,387

    WHY am I getting undefined as a _droptarget?

    Ok, I have a MC with 2 onClipEvent handlers, mouseDown, and mouseUp.

    mouseDown does the startdrag, mouseUp does the stopdrag.

    When I trace eval(this._droptarget), I get undefined. I'm dropping over a MC. I checked the instance type and name of both the droptarget and the dragee. Thrice. The reg point of the dragee is CLEARLY inside the drop target. Undefined is only supposed to be returned when you're dropping it over something that's not a MC. There are no other instances of anything overlappping either instance. I SHOULD be getting a mc reference. If I take out the eval I just get an empty string.

    What gives?!

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    are you using the startDrag and stopDrag methods to control the dragging of the clip?

    the _droptarget property only works if these methods are used,

    for example this works,

    code:

    onClipEvent(mouseDown) {
    if (this.hitTest(_root._xmouse, _root._ymouse)) {
    this.startDrag();
    }
    }
    onClipEvent(mouseUp) {
    trace(eval(this._droptarget));
    this.stopDrag();
    }



    whereas something like this results in the droptarget being undefined,

    code:

    onClipEvent(mouseDown) {
    if (this.hitTest(_root._xmouse, _root._ymouse)) {
    this.drag = true;
    }
    }
    onClipEvent(mouseUp) {
    trace(eval(this._droptarget));
    this.drag = false;
    }
    onClipEvent(enterFrame) {
    if (this.drag) {
    this._x = _root._xmouse;
    this._y = _root._ymouse;
    }
    }


  3. #3
    Retired SCORM Guru PAlexC's Avatar
    Join Date
    Nov 2000
    Location
    NJ
    Posts
    1,387
    Yep. Using startDrag/stopDrag. Though I'm not doing the hittest on the mouse like you are in startDrag, but that shouldn't matter.

  4. #4
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Is there anything on a layer inbetween the clip being dragged and the target that could be obscuring the drop target?

    can you post the fla file?

  5. #5
    Retired SCORM Guru PAlexC's Avatar
    Join Date
    Nov 2000
    Location
    NJ
    Posts
    1,387
    Nope.

    I could post you the FLA but it wouldn't do any good, it gets loaded into this whole complex navigation frame that I really don't want to post.

    But here's the code on the MC.

    code:


    onClipEvent(mouseDown) {
    this.startDrag();

    }

    onClipEvent(mouseUp){
    stopAllSounds();
    stopDrag();
    theDrop = eval(_droptarget);
    trace(this._droptarget);
    trace(eval(this._droptarget));

    if (theDrop == _root.josejoseph) {
    this._x = _root.vars.josejosephx;
    this._y = _root.vars.droptargety;
    gotoAndPlay("correct");
    _root.feedback.gotoAndPlay("a");
    }

    else if ((theDrop == _root.josephdonna) || (theDrop == _root.janefred)) {
    gotoAndPlay("tryagain");
    }

    else {
    this._x = _root.vars.startx;
    this._y = _root.vars.starty;
    }
    }


  6. #6
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hmm,

    I guess there must be something conflicting with this in the rest of the movie. it seems to work exactly as expected here...

    does the movie get loaded into a movie clip? if so there may be some problems there. I did a quick test using,

    this._lockroot = true;

    inside the loaded movie (on its main timeline) to get round the usual problems of _root targeting a different timeline when the movie is loaded into a clip, and this seems to cause eval(this._droptarget) to be undefined.

  7. #7
    Retired SCORM Guru PAlexC's Avatar
    Join Date
    Nov 2000
    Location
    NJ
    Posts
    1,387
    Is _lockroot implemented in MX or MX2004? I'll give it a try.

    The movie is loaded into a level, not another MC. But there are other movies both in levels above and below it.

    Nevermind, _lockroot didn't do crap.
    Last edited by PAlexC; 03-03-2004 at 03:22 PM.

  8. #8
    Junior Member
    Join Date
    Dec 2008
    Posts
    2

    Possible reason

    I am also facing a similar issue and for me the reason is that there is a parent swf which is compiled for FlashPlayer6 and this swf is loading another swf which is compiled for FP8. The FP8 one is behaving as if always lockroot'ed while the path reported by _droptarget (on FP8 swf) refers to the path from Stage onwards.

    HTH

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