ScriptSpot

Forum topic · General Scripting

Script error - RolloutClass

By Matyrix · 2009-12-02

Description

Hello

I'm working on a script nowdays, but I have got some problem with the Rollouts...
I made a very simple script to show you what is my problem. My goal was to create a button, wich can create a new rollout. The most interesting, that the error message is only in the first run of script, when I run this script second time, it's work.
The script:


rollout MENU "MENU"
(
	button On01 "On" width:90 pos:[10,10]
	button Off01 "Off" width:90 pos:[10,40]
	
	on On01 pressed do
		addRollout Rollout01 menu_windo

	on Off01 pressed do
		removeRollout Rollout01 menu_windo
)

rollout Rollout01 "Rollout"
(
	button Button01 "Button" width:90 pos:[10,10]
)


menu_windo = newRolloutFloater "Rollout" 150 180

addRollout MENU menu_windo
addRollout Rollout01 menu_windo

And I got this error message when I run this script first time:
"Type error: CreateDialog requires RolloutClass, got: undefined"

It's a picture about the happenings: https://dl.dropbox.com/u/1152958/script_error.jpg

Thanks your helps in advance.

Matyrix

Comments (8)

fajar · 2009-12-08

menu_windo = newRolloutFloater "Rollout" 150 180
rollout MENU "MENU"
(
button On01 "On" width:90 pos:[10,10]
button Off01 "Off" width:90 pos:[10,40]

on On01 pressed do
addRollout Rollout01 menu_windo

on Off01 pressed do
removeRollout Rollout01 menu_windo
)

rollout Rollout01 "Rollout"
(
button Button01 "Button" width:90 pos:[10,10]
)

addRollout MENU menu_windo
addRollout Rollout01 menu_windo

just testing

holycause · 2009-12-04

thanks Christopher.

I used the [code] tags, but beacause of the spaces, i got some wierd stuff for a maxscript code. lol

 

I ll use the <code> tags. :D

Admin · 2009-12-04

Ahh. I see. I bet you activated the rich text editor right? It adds in all kinds of html formatting that breaks the code snippet.

I find the best way to work most of the time is to just use the simple text box, any links you type will turn to actual links w/o any [url] tags or anything like that and any code pasted in [ code ] blocks will highlight correctly.

On occasion if I really need formatting I'll use rich text...

holycause · 2009-12-03

like this it's working perfectly: 😉

 

 


menu_windo = newRolloutFloater "Rollout" 150 180

rollout Rollout01 "Rollout"
(
button Button01 "Button" width:90 pos:[10,10]
)

rollout MENU "MENU"
(
button On01 "On" width:90 pos:[10,10]
button Off01 "Off" width:90 pos:[10,40]

on MENU open do
(

)
on On01 pressed do addRollout Rollout01 menu_windo

on Off01 pressed do removeRollout Rollout01 menu_windo

)
    addRollout MENU menu_windo
    addRollout Rollout01 menu_windo 

Matyrix · 2009-12-03

Thank you very much, it works :)

holycause · 2009-12-03

it's normal.

Don't forget that maxscript is reading line by line, like you do when you read a book.

In your script you ask it to add or remove rollouts, from the rolloutFloater.

 

But at this time, it doesn t know therolloutFloater, because you create it later in the script.

to prevent this, you should create the rolloutFloater before the rollouts. like this

menu_windo = newRolloutFloater "Rollout" 150 180

rollout MENU "MENU"

(

button On01 "On" width:90 pos:[10,10]

button Off01 "Off" width:90 pos:[10,40]

on On01 pressed do

addRollout Rollout01 menu_windo

on Off01 pressed do

removeRollout Rollout01 menu_windo

)

rollout Rollout01 "Rollout"

(

button Button01 "Button" width:90 pos:[10,10]

)

addRollout MENU menu_windo

addRollout Rollout01 menu_windo

Matyrix · 2009-12-03

Thanks your comment!

Unfortunately your corrected script is not work... I tried to run it on three different computers, but the first time always send error messages... Of course the second run is always works, but it's not a good solution...

What's the wrong?... I don't understand...