Creating a reusable object

Timothy Bleiler bleiler at buffalo.edu
Wed Aug 8 09:04:40 EDT 2012


On Aug 8, 2012, at 12:34 AM, Mark Smith wrote:

> I make a new card. The graphic shows up (shouldn't have if I  
> understand
> "shared group" correctly). So, I try and delete the object from the  
> second
> card and it deletes it from the first card too.
> So, looks like I have a shared object that behaves like a  
> background, not a
> reusable object that responds to messages.
>
> Where did I screw up? Have tried this a few times and always get the  
> same
> result.

Setting BackgroundBehavior of a group to true does 2 major things.
1. When you create a new card, all of the groups on the current card  
whose backgroundBehavior is true will be placed on the new card. If  
you have a background group on multiple cards and want to remove it  
from one card but not others, you must select the group, then under  
the "Object" menu choose "Remove Group".  You add a group to a card   
by selecting the "Object" menu and choosing your group from the "Place  
Group" sub menu. Do NOT use copy and paste to put the group on  
multiple cards, you will be creating new unique controls.

2. The script of a group with backgroundBehavior set to true is  
processed AFTER the card EXCEPT for messages that pass through  
controls within the group. It can get very confusing. If you're going  
to use backgrounds I'd suggest you play around with it until you think  
you understand it before doing a lot of coding.

There have been long discussions over the years about how each of us  
models this in our own heads. I've never heard of one that is simple  
but complete. With that said, one way to think of it is that a group  
with backgroundBehavior set to true is somewhat independent of any  
given card. You might even think of it as another card between the  
card and the stack.  You can have more than one group as a background  
on a card and the order their scripts are processed in the message  
path depends on the groups number relative to the other controls on  
the CURRENT card. They could be in a different order on another card!!  
Definitely, it can be a little tricky to get your head around! This  
article by Richard Gaskin might be of some help getting started. http://www.fourthworld.com/embassy/articles/revolution_message_path.html

Another option is to have a shared control that behaves like any other  
control on a card i.e. its script is processed like a control on the  
card not after the card and is not automatically placed on new cards.  
In this case, do NOT set the backgroundBehavior to true but instead  
just set SharedBehavior to true. Then, to use the group on multiple  
cards, go to the card where you want to use the group, select the  
"Object" menu and choose your group from the "Place Group" sub menu.  
Do NOT use copy and paste to put the group on multiple cards, you will  
be creating new unique controls.

Any group placed on more than one card will have its SharedBehavior  
set to true regardless of the value of its backgroundBehavior property.


Good luck!

Tim Bleiler, Ph.D.
Instructional Designer, HSIT
University at Buffalo




More information about the use-livecode mailing list