PDA

View Full Version : Execute 2 buttons from a button in another rollout


NahuelL
10-11-2010, 03: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

Kameleon
10-11-2010, 03:41 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.

NahuelL
10-11-2010, 04:09 PM
It works perfect! Thank you very much! :)

CGTalk Moderation
10-11-2010, 04:09 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.