Help with Action Script 2

  • ivfi3
  • Born
  • Born
  • No Avatar
  • Joined: Aug 29, 2012
  • Posts: 2
  • Status: Offline

Post August 29th, 2012, 2:03 pm

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
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post August 29th, 2012, 2:03 pm

  • Zealous
  • Guru
  • Guru
  • User avatar
  • Joined: Apr 15, 2011
  • Posts: 1194
  • Loc: Sydney
  • Status: Offline

Post August 30th, 2012, 11:00 pm

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
  • No Avatar
  • Joined: Aug 29, 2012
  • Posts: 2
  • Status: Offline

Post August 31st, 2012, 8:38 am

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
  • Joined: Apr 15, 2011
  • Posts: 1194
  • Loc: Sydney
  • Status: Offline

Post August 31st, 2012, 10:53 pm

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 36 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
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.