Affect Array index via Slider?

Hi there, say I have an array of objects and I want to use a slider to alternate between those objects how would I go about doing this?

I theory I understand that every point on the slider would relate to an index in the array, then the action for every point on the slider would trigger the code to affect that indexed object

i.e. slider position 1 = array index 1
slider action 1 = code to affect array index 1

Any help would be greatly appreciated :)

K

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

Maybe like this:

(
	global rol_sliderTest
	try(destroyDialog rol_sliderTest)catch()
	rollout rol_sliderTest ""
	(
		local obj = undefined
		slider sld_01 ""  range:[0,10,0] type:#integer ticks:10
 
		on rol_sliderTest open do
		(
			obj = objects as array
			sld_01.range = [0,obj.count,0]
		)
 
		on sld_01 changed val do
		(
			if val != 0 do
			(
				print obj[val].name
				obj[val].wirecolor = [(random 0 255),(random 0 255),(random 0 255)]
			)
		)
	)
	createdialog rol_sliderTest 	
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.