Unable to read width from a behaviour button script

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Unable to read width from a behaviour button script

Post by Simon Knight » Fri Apr 01, 2011 11:41 am

I am trying to read the width and height of an image but running into problems. I have a main stack with two sub stacks Assets and Behaviours. Assets has a card that holds a number of png images. The behaviour stack has a card that has buttons that have behaviours defined/written. The main stack has a button that uses a behaviour. The behaviour code sets the icon of the button to that of one of the stored images - this code works. But I wish to resize the host button so that it is large enough to display the image that is assigned to it. Here is my code:

Code: Select all

set the icon of me to theFrame
   set the width of me to the width of  theframe  -- fails
   set the height of me to the height of  theframe -- fails
I have tried variations e.g. set the width of me to the width of image theframe plus typing in the image name directly and also referring to it by ID number. I have tried reading the width in an answer statement but that fails as well.

Any ideas?
best wishes
Skids

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Unable to read width from a behaviour button script

Post by Klaus » Fri Apr 01, 2011 11:53 am

Hi Simon,

"the icon" is the ID of an image. so if:
...
set the icon of me to theFrame
set the width of me to the width of image ID theframe
...
does not work, you may need to add a decsriptor to the image:
...
set the icon of me to theFrame
set the width of me to the width of image ID theframe OF CARD X ## of stack Y
...
Know what I mean?


Best

Klaus

Post Reply