2 Replies Latest reply on Mar 25, 2007 8:30 PM by wgb14

    A puzzle problem

    wgb14 Level 1
      Hi all,

      I have the following problem:

      I have 4 puzzle pieces that i want my user to place somewhere on the screen in sequence (1,2,3,4). Also i would like in case that he selects the wrong number in the sequence to reutrn an altert (wrong try again). For example if he clicks first the third piece instead of the first to return an alert ("Please try again"). I am trying this for some time now, but the combinations seem difficult to compute.

      global gSequenceList, gClickedList

      on startMovie
      gSequenceList = [1,2,3,4]
      gClickedList = []
      end

      property pS, spriteNum
      global gSequenceList, gClickedList

      on beginSprite me
      pS = sprite (spriteNum)
      end

      on mouseUp me


      if gClickedList.count < 4 then
      gClickedList.add (spriteNum)
      end if


      alert (""&gClickedList&"")

      gfirstclick = gSequenceList[1]
      gsecondclick = gSequenceList[2]
      gthirdclick = gSequenceList[3]

      if gClickedList[1] = gfirstclick then --If the user selects the pieces in order
      if gClickedList[2] = gsecondclick then
      alert ("Yes Well done")
      set the loc of sprite pS to point (237,67) --sets the pieces onto the correct location on the stage
      if gClickedList[1] = gthirdclick then
      if gClickedList[2] = gsecondclick then
      alert ("Yes Well done")
      set the loc of sprite pS to point (237,67)

      end if
      end if
      end if
      end if

      if gClickedList.count = 3 then
      if gClickedList[2] = gsecondclick then
      alert ("Yes Well done")
      set the loc of sprite pS to point (237,67)
      end if
      end if

      if gClickedList.count = 2 then
      alert ("Yes Well done")
      set the loc of sprite pS to point (237,67)
      END IF


      if gClickedList.count = 1 then
      If gClickedList[1] = gsecondclick then
      alert ("try again")
      END IF
      end if
      END