Skip to main content
Known Participant
July 15, 2014
Answered

Embedded drag and drop not working

  • July 15, 2014
  • 1 reply
  • 1292 views

Hi,

Hoping someone can help as have got 90% of the way through a project and hit a wall at the final (end-of-level-baddie) problem.

I'm currently embedding old AS2 activities (build by a second party - now not operating/contactable) into a new AS3 menu system.

Most of them I've managed to port across and embed without issue. Unfortunately embedding the drag and drop activity is proving to be, for want of a better phrase, a complete drag.

I've managed to decompile the code, so have put a few trace statements in to find out what might be going wrong. Looking in the collision detection part of the code, the problem appears to be that when the activity is embedded, although the index of the drag clip is returned fine with its corresponding index number, the index of the drop clip is returned as 'undefined'.

The activity works fine in a standalone flash player, with both indexes returning their respective numbers. However not so when it's embedded.

I'm guessing that this is a levels issue, but is there any easy way that I can force the AS2 drag and drop game to act as self-contained and ignore its parent holding clip?

Thanks in advance

This topic has been closed for replies.
Correct answer kglad

reference to _level0 is the problem.

on the first frame of the as2 movie, use:

var tl:MovieClip=this;

then replace all _level0 references with tl.

you may also be able to use:

this._lockroot=true in that first frame and then replace all _level0 references with _root.

p.s. you may have other problems if something like eval(somedroptarget) is used.

1 reply

kglad
Community Expert
Community Expert
July 15, 2014

what code in the as2 files is failing when loaded into an as3 parent?

odgarAuthor
Known Participant
July 15, 2014

Hi kglad,

Thanks for replying (you've helped me out before :-)  )

A search of the classes reveals only one mention of getDepth() on a text field, which is irrelevant at the mo (as the engine's just creating image drag and drops)

The main activity stage is created by an EngineClass (which drives all the activities I've been adapting, but wasn't a problem with less layer critical ones).

There are three lines I can see where the activity stage is created using 'getNextHighestDepth()'

this.mWhere.createEmptyMovieClip("activity_mc", this.mWhere.getNextHighestDepth());

this.mWhere.createEmptyMovieClip("activityMask_mc", this.mWhere.getNextHighestDepth());

this.mWhere.createEmptyMovieClip("toolbars_mc", this.mWhere.getNextHighestDepth());

All the drags and drops are then created within this activity_mc. When I run the activity as standalone (where it works), and drag an item onto a drop zone, the traces I set up on the Drag and Drop items report back the following:

DragObject: _level0.activity_mc.container_mc.dropItem2.dropSkin.greyBorder.whiteBG

DropArea: _level0.activity_mc.container_mc.dropItem2.dropSkin.greyBorder

When I run it embedded in the AS2 wrapper it then fires back the following after an attempted drop:

DragObject: undefined

DropArea: undefined

...and the item refuses to drop on the dropzone, returning to where it came from.

The tiny amount of knowledge I have makes me (probably mistakenly) assume that if I could place the activity_mc layer on root, then everything would be contained within the embedded clip and the layering wouldn't go so wonky. But in reality I've got no idea! To make matters worse, the original drag and drop activity is itself inside another as2 wrapper which contains some navigation buttons...

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
July 15, 2014

reference to _level0 is the problem.

on the first frame of the as2 movie, use:

var tl:MovieClip=this;

then replace all _level0 references with tl.

you may also be able to use:

this._lockroot=true in that first frame and then replace all _level0 references with _root.

p.s. you may have other problems if something like eval(somedroptarget) is used.