-1

I have created some buttons and some graphics on a substack for referencing. I need to be able to click on button to call an instance of one of those graphics onto the main stack. Then I want to be able to drag that graphic onto one of my other buttons and have it replaced with a different graphic. I would love any help with the coding or a link to a tutorial on how to do something similar. For example my basic button is a cups button. When its clicked I want it to create an instance of my "EmptyCup" graphic. But then if I drag the EmptyCup graphic to the CoffeeMachine button I want to replace EmptyCup with CupOCoffee and so on.

Austin
  • 1
  • 1

1 Answers1

0

To put a copy of the graphic in another stack, use the copy command, like this:

copy graphic "EmptyCup" of stack "Resources" to stack "Main Screen"

There are a number of ways to change the graphic when you drag it, but the simplest way is to set the properties you want to change:

on mouseEnter -- goes in the "CoffeeMachine" button script
  set the style of graphic "EmptyCup" to \
     the style of graphic "CupOCoffee" of stack "Resources"
  -- you can set other properties as well, such as the backColor, etc.
end mouseEnter

If you're using images rather than graphics, set the imageData property instead (after making sure the image's size is the same as the one whose imageData you want to use):

set the width of image "EmptyCup" to ]
   the width of image "CupOCoffee" of stack "Resources"
set the height of image "EmptyCup" to ]
   the height of image "CupOCoffee" of stack "Resources"
set the imageData of image "EmptyCup" to ]
   the imageData of image "CupOCoffee" of stack "Resources"