Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Drag and Drop objects to the same target

New Here ,
Jan 09, 2014 Jan 09, 2014

Can any one assist? I have a box that has six labels that can be dropped on targets on the box. I have all this in place but I want to be able to have label 2 drop onto target 2 and 3, and likewise label 3 drop on to target 2 and 3. All others drop onto their specific targets. This is the script so far but ony for matching object to target. Please be gentle, i'm new to this!!

event.target.stopDrag();

var myTargetName:String="target" + event.target.name;

var myTarget:DisplayObject=getChildByName(myTargetName);

if (event.target.dropTarget!=null&&event.target.dropTarget.parent==myTarget)

Can anyone assist please?

TOPICS
ActionScript
284
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 10, 2014 Jan 10, 2014
LATEST

What you could do is have an array assigned to each dragged item that defines the allowed targets for each dragged item and check if the dropTarget is in the array using the indexOf() method.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines