Help with Action Script 2

  • ivfi3
  • Born
  • Born
  • ivfi3
  • Posts: 2

Post 3+ Months Ago

Friends, please help with this code, it is to make a kind of puzzle but does not work; Here is the code for the button "p1".
"p1copy" is a movieclip that is in the place where the piece should go.
In addition to this there code in the frame to make invisible "p1copy"
The error consists in where you want to make the "release" returns to the original position; does the function hide "p1" to make visible "p1copy"
I hope can help me, thank you
Code: [ Select ]
on (press) {
    startDrag("p1");
}
on (release) {
    stopDrag();
}
on (release) {
    if (_droptarget eq "p1copy")
    {
        setProperty("p1", _visible, false);
        setProperty("p1copy", _visible, true);
    }
    else
    {
        setProperty("p1", _x, "707");
        setProperty("p1", _y, "276");
    }
}
  1. on (press) {
  2.     startDrag("p1");
  3. }
  4. on (release) {
  5.     stopDrag();
  6. }
  7. on (release) {
  8.     if (_droptarget eq "p1copy")
  9.     {
  10.         setProperty("p1", _visible, false);
  11.         setProperty("p1copy", _visible, true);
  12.     }
  13.     else
  14.     {
  15.         setProperty("p1", _x, "707");
  16.         setProperty("p1", _y, "276");
  17.     }
  18. }
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1244
  • Loc: Sydney

Post 3+ Months Ago

edited.....checking again

(just note not 100% on AS)

would eq be =

Code: [ Select ]
on (release) {
  if (_droptarget eq "p1copy")
  {
  1. on (release) {
  2.   if (_droptarget eq "p1copy")
  3.   {

i have been looking at these 2 open brackets thinking that there is 1 too many.

Code: [ Select ]
on (release) {
  if (_droptarget eq "p1copy")
  {setProperty("p1", _visible, false);
   setProperty("p1copy", _visible, true);}
  }

  else
  1. on (release) {
  2.   if (_droptarget eq "p1copy")
  3.   {setProperty("p1", _visible, false);
  4.    setProperty("p1copy", _visible, true);}
  5.   }
  6.   else


i think i have had a long day but i am thinking you have not closed the variables correctly.

i would need to test it more but that looks close to working reading it.

idk tell me what you think. good chance i am wrong lol
  • ivfi3
  • Born
  • Born
  • ivfi3
  • Posts: 2

Post 3+ Months Ago

Thanks for the reply I already found a functional code; This annex who may need it. Both instances must be MC
Code: [ Select ]
on (press) {
    startDrag(this);
    this.swapDepths(100);
    
}
on (release) {
    stopDrag();
}
on (release) {
    if (_droptarget eq "/p1copy")
    {
        setProperty(this, _x,387);
        setProperty(this, _y, 519);
    }
    else
    {
        setProperty(this, _x, "707");
        setProperty(this, _y, "276");
    }
}
  1. on (press) {
  2.     startDrag(this);
  3.     this.swapDepths(100);
  4.     
  5. }
  6. on (release) {
  7.     stopDrag();
  8. }
  9. on (release) {
  10.     if (_droptarget eq "/p1copy")
  11.     {
  12.         setProperty(this, _x,387);
  13.         setProperty(this, _y, 519);
  14.     }
  15.     else
  16.     {
  17.         setProperty(this, _x, "707");
  18.         setProperty(this, _y, "276");
  19.     }
  20. }
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1244
  • Loc: Sydney

Post 3+ Months Ago

i see the changes, good that you got it working.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 11 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.