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

Draggable object back to original position when already there is an object at the drop area.

Explorer ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

I'm a newbie about flash, especially actionscript.

So the scenario is something like: I have 3 pairs of shoes, 2 ties, and 4 scouts.

I already made the 3 pairs of shoes and 2 ties draggable to any scouts (as the drop area).

But the problem is, I want to make it clear, that the user only may put a pair of shoes and a tie on 1 scout.

Because what I have now is, when already exist a pair of shoes and a tie on a scout, the user still can drop other on it.

Please help me, I've been surfing through internet and many forums but still can't solve this one. Many thanks before.

Here is my code for one of my movie clip

on (press)

{

  if (!this.isLocked)

  startDrag(this);

}

on (release) {stopDrag();

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

{

  this._x=193,75;

  this._y=358,90;

  var efeksound:Sound = new Sound();

  efeksound.attachSound("plopp");

  efeksound.start();

  var isLocked = true;

}

else if(this._droptarget=="/anak2")

{

  this._x=324,25;

  this._y=358,90;

  var efeksound:Sound = new Sound();

  efeksound.attachSound("plopp");

  efeksound.start();

  var isLocked = true;

}

else if(this._droptarget=="/anak3")

{

  this._x=453,75;

  this._y=358,90;

  var efeksound:Sound = new Sound();

  efeksound.attachSound("plopp");

  efeksound.start();

  var isLocked = true;

}

else{

  this._x=600,20;

  this._y=342,8;

}

}

TOPICS
ActionScript

Views

509

Translate

Translate

Report

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

Explorer , Feb 18, 2017 Feb 18, 2017

Solved!

I hope this help for you who has the same problem.

anak1,2,3 is the instance name for the scouts.

dasianak1 is a var that happen when already there exist a tie in scout 1 (anak1), and so on to 2,3

on (press)

{

  if (!this.isLocked)

  startDrag(this);

}

on (release)

{

stopDrag();

if(this._droptarget=="/anak1" && _parent.dasianak1 == false)

{

  this._x=216;

  this._y=401,95;

  var efeksound:Sound = new Sound();

  efeksound.attachSound("plopp");

  efeksound.start();

  var isLocked = true;

  _parent.dasianak1 =

...

Votes

Translate

Translate
Explorer ,
Feb 18, 2017 Feb 18, 2017

Copy link to clipboard

Copied

LATEST

Solved!

I hope this help for you who has the same problem.

anak1,2,3 is the instance name for the scouts.

dasianak1 is a var that happen when already there exist a tie in scout 1 (anak1), and so on to 2,3

on (press)

{

  if (!this.isLocked)

  startDrag(this);

}

on (release)

{

stopDrag();

if(this._droptarget=="/anak1" && _parent.dasianak1 == false)

{

  this._x=216;

  this._y=401,95;

  var efeksound:Sound = new Sound();

  efeksound.attachSound("plopp");

  efeksound.start();

  var isLocked = true;

  _parent.dasianak1 = true;

}

else if(this._droptarget=="/anak1" && _parent.dasianak1 == true)

{

  this._x=925,50;

  this._y=408,95;

}

else if(this._droptarget=="/anak2" && _parent.dasianak2 == false)

{

  this._x=346;

  this._y=401,95;

  var efeksound:Sound = new Sound();

  efeksound.attachSound("plopp");

  efeksound.start();

  var isLocked = true;

  _parent.dasianak2 = true;

}

else if(this._droptarget=="/anak2" && _parent.dasianak2 == true)

{

  this._x=925,50;

  this._y=408,95;

}

else if(this._droptarget=="/anak3" && _parent.dasianak3 == false)

{

  this._x=476;

  this._y=401,95;

  var efeksound:Sound = new Sound();

  efeksound.attachSound("plopp");

  efeksound.start();

  var isLocked = true;

  _parent.dasianak3 = true;

}

else if(this._droptarget=="/anak3" && _parent.dasianak3 == true)

{

  this._x=925,50;

  this._y=408,95;

}

else

{

  this._x=925,50;

  this._y=408,95;

}

}

Votes

Translate

Translate

Report

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