1. Here some code for a solution:
property spriteNum
on mouseWithin
colorIntersect
end
on mouseLeave
colorIntersect
end
on mouseEnter
colorIntersect
end
on colorIntersect
if sprite(101).intersects(spriteNum) then
sprite(spriteNum).color = rgb(255,0,0)
else
if sprite(102).intersects(spriteNum) then
sprite(spriteNum).color = rgb(0,255,0)
else
if sprite(103).intersects(spriteNum) then
sprite(spriteNum).color = rgb(255,255,0)
else
if sprite(104).intersects(spriteNum) then
sprite(spriteNum).color = rgb(0,0,255)
else
if sprite(105).intersects(spriteNum) then
sprite(spriteNum).color = rgb(128,128,128)
else
sprite(spriteNum).color = rgb(0,0,0)
end if
end if
end if
end if
end if
end
I declared the spriteNum property and instead of refering to the actual sprite, use spriteNum. But you have to put this behavoir on each box sprite. Thats why the three handlers mouseWithin, mouseEnter, mouseLeave are refering to colorIntersect. The interaction seemed fine with this.The only thing is a box will not change back unless the circle hits another box, but if the game is similar to monopoly then your boxes are close together and should not have a problem with this. This could be all you need.
2 I also tried using the sendAllSprites property but it was problematic with a frame script. But if you want to try that it would go something like:
(the pertinent parts of your frame script)
property spriteNum
on enterFrame
colorIntersect
end
on colorIntersect
if sprite(101).intersects(spriteNum) then
sprite(spriteNum).color = rgb(255,0,0)
else
if sprite(102).intersects(spriteNum) then
sprite(spriteNum).color = rgb(0,255,0)
else
if sprite(103).intersects(spriteNum) then
sprite(spriteNum).color = rgb(255,255,0)
else
if sprite(104).intersects(spriteNum) then
sprite(spriteNum).color = rgb(0,0,255)
else
if sprite(105).intersects(spriteNum) then
sprite(spriteNum).color = rgb(128,128,128)
else
sprite(spriteNum).color = rgb(0,0,0)
end if
end if
end if
end if
end if
end
Then the script for your behavoirs to be placed on your boxes:
property spriteNum
property SendAllSprites
on beginSprite
sendAllSprites #colorIntersect
end
First, for some reason the frame script does not like the spriteNum (so there is an error when you try to run it) and secondly the beginSprite handler does not execute. So refer back to solution 1. Hope this helps out.