So for example, create a stack only stack named "Button Behaviors" with the following code
Code: Select all
on mouseUp
getTarget
end mouseUp
command getTarget
switch the owner of the target
case "card id 1002"
switch the target
case "button " "e&"1""e
answer "HI button 1 of card 1002"
break
case "button " "e&"2""e
answer "HI button 2 of card 1002"
break
case "button " "e&"3""e
answer "HI button 3 of card 1002"
break
end switch
break
case "card id 1006"
switch the target
case "button " "e&"1""e
answer "HI button 1 of card 1006"
break
case "button " "e&"2""e
answer "HI button 2 of card 1006"
break
case "button " "e&"3""e
answer "HI button 3 of card 1006"
break
end switch
break
end switch
end getTarget
Then create a normal stack with 2 cards make sure the card are named "card id 1002" and "card id 1006"
Add 3 buttons on each card named "1","2","3"
Add to the card script
Code: Select all
on openStack
start using stack "Button Behaviors"
end openStack
Testing for the owner of the target allows for the same named controls to be on multiple cards, so the above example has 2 cards, 6 buttons and 1 script only stack for all of the 6 button actions.
I haven't as yet had any problems with this method and it has reduced the number of scripts in my projects considerably.
So what do you think? Can you see any pitfalls or problems I might be building for the future?