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

Drag & Drop Issue (locking to target object)

Community Beginner ,
Aug 28, 2013 Aug 28, 2013

Hi,

I've been working with an interactive game and I've set up my objects (to drag) in one layer with their object targets in another. Export settings Flash 8 AS2 (requirement for the site it's being uploaded to).

My objects have to snap back to their original position if they don't land on their target, and I have that working. What I can't get to work is for the object to snap into the box I've created.

Both the object and the target have been converted to movie clips and the taget has been given an instance name (targetone) I've used that instance name in the action script that's been put on the object. Both target and object have their anchor points centred for X,Y purposes.

Here is my actionscript:

on (press)

{

    startDrag(this);

}

on (release)

{

    stopDrag();

if(this._droptarget =="/targetone")

{

    this._x=_/targetone._x;

    this._y=_/targetone._y;

}

else{

this._x = 319.95;

this._y = 138.75;

}

}

It just won't snap into the box. The object is text converted to paths (large text) and the box is also large. I tried increasing it as I thought it may be having issues with locking in but to no avail

Any help would be greatly appreciated!

Stu

TOPICS
ActionScript
1.6K
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

correct answers 1 Correct answer

Community Beginner , Aug 29, 2013 Aug 29, 2013

Thanks for the reply, Ned.

After a few hours of testing different script code, including your suggestions, I tried drawing an object directly onto the stage and it worked.

I'm using boxes that are .ai files and they have been imported to the library with all of their layers and effects intact (as seperate components). I've discovered that the boxes I designed in Illustrator are too complicated to assign code to - I'm guessing it's because it has layers.

I've got round it by drawing a simple box in

...
Translate
LEGEND ,
Aug 28, 2013 Aug 28, 2013

First use a trace to make sure that the target you are hitting agrees with the target you are indicating: "/targetone"

I don't recall ever seeing something targeted using the syntax you show....  _/targetone

Try using _root.targetone or _level0.targetone instead and see if that helps.

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
Community Beginner ,
Aug 29, 2013 Aug 29, 2013
LATEST

Thanks for the reply, Ned.

After a few hours of testing different script code, including your suggestions, I tried drawing an object directly onto the stage and it worked.

I'm using boxes that are .ai files and they have been imported to the library with all of their layers and effects intact (as seperate components). I've discovered that the boxes I designed in Illustrator are too complicated to assign code to - I'm guessing it's because it has layers.

I've got round it by drawing a simple box in Flash, positioning it over the illustrator versions and making it invisible. Problem solved!

Case closed

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