Notifications
Clear all
[Closed] Accessing elements from different rollouts
Jul 15, 2007 4:20 am
I can’t wrap my head around this one. Here’s an example of what I mean, I’ve included the code. Let’s say I wanted to access the value of the spinner from the 2nd rollout from the first one. I know you can access it by going
subRollout02.testSP.value
but this won’t work when using a macro. Am i missing something?
[size=3]rollout[/size] mainRoll "Main Rollout" height: 150
(
subRollout sub01 height: 70
subRollout sub02 height: 70
)
rollout subRoll01 "Sub rollout 01"
(
button testBUT "Print Value"
on testBUT pressed do
(
print testSP.value
)
)
rollout subRoll02 "Sub rollout 02"
(
spinner testSP "Spinner" range:[0,100,50]
)
createDialog mainRoll
addSubRollout mainRoll.sub01 subRoll01
addSubRollout mainRoll.sub02 subRoll02
4 Replies
Jul 15, 2007 4:20 am
You need to define the rollout you want to access as a global variables.
macroscript someTestRollouts category:"Your Tools" buttonText:"Test Rollouts"
(
global mainRoll
global subRoll01
global subRoll02
rollout mainRoll "Main Rollout" height: 150
(
subRollout sub01 height: 70
subRollout sub02 height: 70
)
rollout subRoll01 "Sub rollout 01"
(
button testBUT "Print Value"
on testBUT pressed do
(
print subRoll02.testSP.value
)
)
rollout subRoll02 "Sub rollout 02"
(
spinner testSP "Spinner" range:[0,100,50]
)
createDialog mainRoll
addSubRollout mainRoll.sub01 subRoll01
addSubRollout mainRoll.sub02 subRoll02
)
Jul 15, 2007 4:20 am
It will also work if you declare them as locals. This is probably a matter of personal preference, but in my experience it’s better to use locals unless there’s no way around using globals.
Cheers,
Martijn
Jul 15, 2007 4:20 am
Ah, so it does. I agree, avoiding to pollute global space can help in the long run.