Notifications
Clear all

[Closed] Script error"CreateDialog requires RolloutClass, got: undefined'

Hello,
I have got some problem with the Rollouts…
that the error message is only in the first run of script, when I run this script second time, it’s work.
And I got this error message when I run this script first time:
“Type error: CreateDialog requires RolloutClass, got: undefined”
Thanks help!!
The script:
global one
try(destroyDialog one )catch()
rollout one “Rollout One” width:162 height:137
(
checkbutton ckb1 “1” pos:[4,3] width:51 height:20 checked:true
checkbutton ckb2 “2” pos:[56,3] width:51 height:20
checkbutton ckb3 “3” pos:[108,3] width:51 height:20
GroupBox grp1 “” pos:[4,16] width:155 height:115
colorPicker cp1 “ColorPicker” pos:[27,47] width:109 height:18
dropdownList ddl1 “DropDownList” pos:[24,74] width:117 height:40

on ckb1 changed state do
(
ckb1.state = true
)
on ckb2 changed state do
(
local dialogpos = getdialogpos one
createdialog two pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
destroydialog one	
)
on ckb3 changed state do
(
local dialogpos = getdialogpos one
createdialog three pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
destroydialog three
)

)

rollout two “Rollout Two” width:162 height:137
(
checkbutton ckb1 “1” pos:[4,3] width:51 height:20
checkbutton ckb2 “2” pos:[56,3] width:51 height:20 checked:true
checkbutton ckb3 “3” pos:[108,3] width:51 height:20
GroupBox grp1 “” pos:[4,16] width:155 height:115
progressBar pb1 “ProgressBar” pos:[16,47] width:123 height:15
slider sld1 “Slider” pos:[15,76] width:127 height:44

on ckb1 changed state do
(
local dialogpos = getdialogpos two
createdialog one pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
destroydialog two		
)
on ckb2 changed state do
(
ckb2.state = true		
)
on ckb3 changed state do
(
local dialogpos = getdialogpos two
createdialog three pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
destroydialog two
)

)

rollout three “Rollout Three” width:162 height:137
(
checkbutton ckb1 “1” pos:[4,3] width:51 height:20
checkbutton ckb2 “2” pos:[56,3] width:51 height:20
checkbutton ckb3 “3” pos:[108,3] width:51 height:20 checked:true
GroupBox grp1 “” pos:[4,16] width:155 height:115
radioButtons rdo1 “RadioButtons” pos:[14,46] width:29 height:78 labels:#(“1”, “2”, “3”, “4”,“5”,“6”,“7”,“8”) default:1 columns:2

on ckb1 changed state do
(
local dialogpos = getdialogpos three
createdialog one pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
destroydialog three		
)
on ckb2 changed state do
(
local dialogpos = getdialogpos three
createdialog two pos:dialogpos style:#(#style_toolwindow, #style_sysmenu)
destroydialog three
)
on ckb3 changed state do
(
ckb3.state = true	
)

)

createdialog one style:#(#style_toolwindow, #style_sysmenu)

4 Replies

Maxscript evaluates the script from top to bottom when it’s run. This means that by the time it reaches your call to create a rollout “two”, this rollout hasn’t been defined yet. And in the second rollout, “one” has been defined, but “three” hasn’t yet.
This is of course a little annoying, but fairly easy to overcome. By declaring all your rollout variables like you did with “global one” before implementing the rollouts themselves, it will work.

oh , I understand.
Thanks Pjanssen!!!

you could also set up functions to take the dialog name as a parameter when they are called, that way everything is set and passed through functions. i’ve done that in the past to get around global variables… but i’m not sure which is better / worse

p.s. pjanssen, i use your outliner all the time. i love it, but i have run into a couple buggish things with it. are you still keeping it up to date or just letting it go at this point? doesn’t look like there’s been much recent activity on the scriptspot page.

1 Reply
(@pjanssen)
Joined: 11 months ago

Posts: 0

Yeah avoiding global variables is definitely something you should try to do.
Wrapping them in structs is also a good way to minimize the amount of variables and functions exposed to the outside. Especially now that structs can have private members in max2010.

p.s. pjanssen, i use your outliner all the time. i love it, but i have run into a couple buggish things with it. are you still keeping it up to date or just letting it go at this point? doesn’t look like there’s been much recent activity on the scriptspot page.

Thanks! In the last couple of days I’ve actually been looking at the outliner again. The topic here on cgtalk was closed because of inactivity. But I was considering opening a new topic here to gather some feedback for a new version. I’ll do that tonight, so you can give you input! (I’ll drop you a PM)