Notifications
Clear all
[Closed] Execute 2 buttons from a button in another rollout
Oct 11, 2010 4:27 pm
Hey guys,
I’m trying to execute 2 buttons that are in Rollout “A” from a button in Rollout “B”.
Here is a simple example i made.
(
try(destroyDialog test)catch()
rollout a "A"
(
button render_1 "Render"
fn render_a =
(
sphere()
max quick render()
delete $sphere01
)
on render_1 pressed do
(
render_a()
)
)
rollout b "B"
(
button render_2 "Render"
fn render_b =
(
box()
max quick render()
delete $box01
)
on render_2 pressed do
(
render_b()
)
)
rollout main "Main"
(
button render_main "Render a"
on render_main pressed do
(
render_a()
render_b()
)
)
rollout test "Test"
(
subrollout rol "" width:325 height:350
)
)
createdialog test width:350 height:350
AddSubRollout test.rol a
AddSubRollout test.rol b
AddSubRollout test.rol main
It throws this error: Call needs function or class, got: undefined
Thanks
Nahuel
2 Replies
Oct 11, 2010 4:27 pm
The problem is that you’re trying to call functions that are defined in the local scope of their rollouts. You have 3 options:
- Move the functions outside the rollouts, making them visible to both A, B and Main.
- Use test.rol.a.render_a() and rest.rol.b.render_b() to call the functions from the Main rollout
- Use test.rol.a.render_1.pressed() and test.rol.b.render_2.pressed() to call the pressed event in each of the buttons.
on render_main pressed do
(
test.rol.a.render_a()
test.rol.b.render_b()
test.rol.a.render_1.pressed()
test.rol.b.render_2.pressed()
)
Hope this helps.