home *** CD-ROM | disk | FTP | other *** search
- property spriteNum, startLoc, topZ, myAction, myNextaction, Active, myActiveState, tagretSp, myName
- global dropZones, DropCount
-
- on beginSprite me
- DropCount = 0
- Active = 1
- startLoc = sprite(spriteNum).loc
- sprite(spriteNum).moveableSprite = 0
- myName = sprite(spriteNum).member.name
- if myName = "lit_side" then
- myName = "lit"
- end if
- myAction = "None"
- topZ = 50
- end
-
- on mouseDown me
- if Active then
- if the doubleClick then
- cursor(0)
- sprite(spriteNum).moveableSprite = 0
- else
- cursor(290)
- sprite(spriteNum).locZ = topZ
- sendAllSprites(#activeSwitch, "off", spriteNum)
- sprite(spriteNum).moveableSprite = 1
- myAction = "Dragging"
- end if
- end if
- end
-
- on mouseUp me
- if Active then
- sprite(spriteNum).locZ = spriteNum
- sendAllSprites(#activeSwitch, "on", spriteNum)
- sprite(spriteNum).moveableSprite = 1
- myAction = myNextaction
- end if
- end
-
- on testValidDrop me
- tagretSp = 0
- repeat with x = 1 to count(dropZones)
- if sprite(spriteNum).intersects(dropZones[x]) then
- tagretSp = dropZones[x]
- exit repeat
- end if
- end repeat
- return sprite(tagretSp).member.name = (myName & "_zone")
- end
-
- on DropMe me
- Active = 0
- sendSprite(tagretSp, #myItem, myName)
- sprite(spriteNum).loc = startLoc
- sprite(spriteNum).blend = 50
- sprite(spriteNum).moveableSprite = 0
- DropCount = DropCount + 1
- puppetSound(1, "click")
- if DropCount = count(dropZones) then
- sendAllSprites(#testCircuit)
- end if
- end
-
- on exitFrame me
- case myAction of
- "Dragging":
- dropOK = me.testValidDrop()
- if dropOK then
- myNextaction = "Add"
- else
- myNextaction = "Return"
- end if
- "Add":
- cursor(0)
- myAction = "None"
- me.DropMe()
- "Return":
- incx = (sprite(spriteNum).loc[1] - startLoc[1]) / 2
- incy = (sprite(spriteNum).loc[2] - startLoc[2]) / 2
- sprite(spriteNum).loc = startLoc + point(incx, incy)
- if me.distanceCheck(startLoc, sprite(spriteNum).loc) < 3 then
- sprite(spriteNum).loc = startLoc
- myAction = "None"
- end if
- cursor(0)
- "None":
- end case
- end
-
- on distanceCheck me, obj1, obj2
- return sqrt(power(obj1[1] - obj2[1], 2) + power(obj1[2] - obj2[2], 2))
- end
-
- on Hide me
- Active = 1
- end
-
- on show me
- Active = 0
- end
-
- on activeSwitch me, val, spNum
- if spNum <> spriteNum then
- if val = "off" then
- myActiveState = Active
- Active = 0
- else
- Active = myActiveState
- end if
- end if
- end
-
- on mouseWithin me
- if Active and (myAction <> "Dragging") then
- cursor(260)
- end if
- end
-
- on mouseEnter me
- if Active and (myAction <> "Dragging") then
- cursor(260)
- end if
- end
-
- on mouseLeave me
- if Active and (myAction <> "Dragging") then
- cursor(0)
- end if
- end
-