badoumba
04-28-2008, 12:03 PM
Hello,
I have to build a project based on a floater including a head rollout (static) followed by a dynamic rollout (displayed after a specific action) and a last foot rollout (static)
The first lauch crashes because my main floater variable is not recognise by my function which updates the rollouts. The second launch is ok since my variable exists for the function.
I tried many attempts to fix this skeleton before to go further without any success.
If someone has a suggestion or a better solution. I am not programmer so I don't know the best way to achieve this, just made this from offline help.
Thanks a lot
here is my code:
--///////////////////////////VARIABLES///////////////////////////////////////
--controls attributes
btnState_createObject=true
btnState_removeObject=false
--dynamic rollout display
displayDynaRollout=false
--floater settings
defaultRolloutHeight=125
defaultRolloutWidth=350
rolloutHeight=defaultRolloutHeight
rolloutWidth=defaultRolloutWidth
defaultRolloutPosX=50
defaultRolloutPosY=120
mainFloater=newRolloutFloater "Dynamic rollouts" defaultRolloutWidth defaultRolloutHeight defaultRolloutPosX defaultRolloutPosY
--Rollouts display update---------------------------------------------------------------------------
function majRollouts =
(
--initalize size for floater
rolloutHeight=defaultRolloutHeight
rolloutWidth=defaultRolloutWidth
--destroy all the rollouts
for roll in mainFloater.rollouts do removeRollout roll mainFloater
--rebuild all the rollouts
addrollout rolloutHead mainFloater --ERROR FIRST LAUNCH:removeRollout requires RolloutClass, got:undefined"
if displayDynaRollout then
(
addRollout rolloutA mainFloater
rolloutHeight+=60
)
addrollout rolloutFoot mainFloater
--adjust the size
mainFloater.size=[rolloutWidth,rolloutHeight]
)
--Controls display update------------------------------------------------------------------------
--This is not really necessary there but need it for my bigger project
function majControls =
(
rolloutHead.btn_createObject.enabled=btnState_createObject
rolloutHead.btn_removeObject.enabled=btnState_removeObject
)
--Create an object--------------------------------------------------------------------
function createObject =
(
global gizmoObject=sphere name:"object" radius:100 segs:20 hemisphere:0.5
--Rollouts
displayDynaRollout=true
--controls
btnState_createObject=false
btnState_removeObject=true
)
--Destroy the Object --------------------------------------------------------
function destroyObject =
(
delete gizmoObject
--Rollouts
displayDynaRollout=false
--Controls
btnState_createObject=true
btnState_removeObject=false
)
--/////////////////////////USER INTERFACE/////////////////////////////////////////////////////////////////////////////////////////
rollout rolloutHead "Steady head rollout"
(
button btn_createObject "Create object" height:18 width:150 offset:[-80,5] enabled:btnState_createObject
button btn_removeObject "Remove object" height:18 width:150 offset:[80,-23] enabled:btnState_removeObject
--SKY CREATION ok
on btn_createObject pressed do
(
createObject()
majRollouts()
majControls()
)
--SKY DESTRUCTION ok
on btn_removeObject pressed do
(
destroyObject()
majRollouts()
majControls()
)
)
rollout rolloutA "Dynamic rollout"
(
colorpicker col_ObjectColor "color" color:[137,204,255]
)
rollout rolloutFoot "Steady foot rollout"
(
button btn_close "Close floater" height:18 width:150
)
addRollout rolloutHead mainFloater
addRollout rolloutFoot mainFloater
I have to build a project based on a floater including a head rollout (static) followed by a dynamic rollout (displayed after a specific action) and a last foot rollout (static)
The first lauch crashes because my main floater variable is not recognise by my function which updates the rollouts. The second launch is ok since my variable exists for the function.
I tried many attempts to fix this skeleton before to go further without any success.
If someone has a suggestion or a better solution. I am not programmer so I don't know the best way to achieve this, just made this from offline help.
Thanks a lot
here is my code:
--///////////////////////////VARIABLES///////////////////////////////////////
--controls attributes
btnState_createObject=true
btnState_removeObject=false
--dynamic rollout display
displayDynaRollout=false
--floater settings
defaultRolloutHeight=125
defaultRolloutWidth=350
rolloutHeight=defaultRolloutHeight
rolloutWidth=defaultRolloutWidth
defaultRolloutPosX=50
defaultRolloutPosY=120
mainFloater=newRolloutFloater "Dynamic rollouts" defaultRolloutWidth defaultRolloutHeight defaultRolloutPosX defaultRolloutPosY
--Rollouts display update---------------------------------------------------------------------------
function majRollouts =
(
--initalize size for floater
rolloutHeight=defaultRolloutHeight
rolloutWidth=defaultRolloutWidth
--destroy all the rollouts
for roll in mainFloater.rollouts do removeRollout roll mainFloater
--rebuild all the rollouts
addrollout rolloutHead mainFloater --ERROR FIRST LAUNCH:removeRollout requires RolloutClass, got:undefined"
if displayDynaRollout then
(
addRollout rolloutA mainFloater
rolloutHeight+=60
)
addrollout rolloutFoot mainFloater
--adjust the size
mainFloater.size=[rolloutWidth,rolloutHeight]
)
--Controls display update------------------------------------------------------------------------
--This is not really necessary there but need it for my bigger project
function majControls =
(
rolloutHead.btn_createObject.enabled=btnState_createObject
rolloutHead.btn_removeObject.enabled=btnState_removeObject
)
--Create an object--------------------------------------------------------------------
function createObject =
(
global gizmoObject=sphere name:"object" radius:100 segs:20 hemisphere:0.5
--Rollouts
displayDynaRollout=true
--controls
btnState_createObject=false
btnState_removeObject=true
)
--Destroy the Object --------------------------------------------------------
function destroyObject =
(
delete gizmoObject
--Rollouts
displayDynaRollout=false
--Controls
btnState_createObject=true
btnState_removeObject=false
)
--/////////////////////////USER INTERFACE/////////////////////////////////////////////////////////////////////////////////////////
rollout rolloutHead "Steady head rollout"
(
button btn_createObject "Create object" height:18 width:150 offset:[-80,5] enabled:btnState_createObject
button btn_removeObject "Remove object" height:18 width:150 offset:[80,-23] enabled:btnState_removeObject
--SKY CREATION ok
on btn_createObject pressed do
(
createObject()
majRollouts()
majControls()
)
--SKY DESTRUCTION ok
on btn_removeObject pressed do
(
destroyObject()
majRollouts()
majControls()
)
)
rollout rolloutA "Dynamic rollout"
(
colorpicker col_ObjectColor "color" color:[137,204,255]
)
rollout rolloutFoot "Steady foot rollout"
(
button btn_close "Close floater" height:18 width:150
)
addRollout rolloutHead mainFloater
addRollout rolloutFoot mainFloater
