Hello bderry ,
good work for a first time with events !
Thank you for your sample code and the subject it brings.
Compilation error code BC31029 indicates a mismatch between the signature of the event and the function to handle this event.
For OnSceneState event , this happens if you use long type for State parameter : it can be fixed if you change it to a integer.
For OnClear event, the error shouldn't be raised , that's strange.
A script like this one should compile without errors (it's ok within Xpression Designer 6.7 and 8.0 ) :
Dim WithEvents fb as xpOutputFrameBuffer
Public sub OnSceneState(ByVal Scene As xpScene, ByVal State As integer ) Handles fb.OnSceneState
end sub
Private sub Cleared() Handles fb.OnClear
End Sub
Using "WithEvents" and "Handles" clause is the standard way of associating an event with an event handler and it's done at compile time.
[FONT=arial]In your sample code fb [/FONT]object is retrieved after compilation : that may explain why it's not working.
To avoid this , you can use dynamic event handling instead with AddHandler clause :
Dim myFb as xpOutputFrameBuffer = Nothing
public sub MyHandlerCreation(byval Engine as xpEngine)
Dim fb1 as xpOutputFrameBuffer = Nothing
' be sure to add handler only once
if myFb is Nothing and Engine.GetOutputFrameBuffer(0,fb1) then
myFb = fb1
AddHandler myFb.OnClear , AddressOf Cleared
end if
end sub
Public sub Cleared()
' Do something here
' Engine.DebugMessage("Cleared Test",0)
End Sub
a call to MyHandlerCreation function will create the handler .
Hope it helps.
#XPression