How to handle one images with many images inside

Jim Lambert jiml at netrin.com
Tue Jul 28 15:04:59 EDT 2009


On Jul 28, 2009, at 10:00 AM, Josep wrote:

> I found some resources images in png
> that inside the file have the three status for the button. Now I cut  
> and
> export to three diferents files each of the status images and asign  
> them.
> The question is if is posible handle in some way the dinamic asign  
> of one
> part of the image to the status of the button. I don't know if I  
> explain
> myself... :)

Josep,

Another approach that is quite handy is to create one image having  
each your button states arranged vertically.
Say you have two states and you want the button to be 200 x 150.
Make one image that is 200 x 300.
The top half of the image depicts one button state; the bottom half  
depicts the other button state.

Now set the size of the button to 200 x 150 and the icon of the button  
to your image.

Then use the topmargin to move the image up and down within the button.

This will display the top part of the image:
	set the topmargin of btn "myStatefulButton" to 150

This will display the bottom part:
	set the topmargin of btn "myStatefulButton" to -150

This will toggle between the two states:
	on mouseUp
	   set the topmargin of me to -(the topmargin of me )
	end mouseUp

Of course, you can have more than two states, just keep adding to your  
image. A four state image would be 200 x 600.

Jim Lambert




More information about the use-livecode mailing list