Page 1 of 1

COmate and Flash ocx problem:can't register event handler

Posted: Mon Dec 29, 2008 10:38 am
by john lory
hi all:
my code like below:

FlashObject = COMate_CreateObject("ShockwaveFlash.ShockwaveFlash", GadgetID(0))

If FlashObject
Debug(FlashObject\SetEventHandler(@myEventCallback()))
Debug COMate_GetLastErrorDescription()
....

Procedure myEventCallback(object.COMateObject, eventName.s, parameterCount)
Debug "----object----"
Debug object
Debug "---event name ---"
Debug eventName
Debug "-----parameterCount---"
Debug s
EndProcedure

.....

in debug window show:
-2147319765
No type description was found in the library with the specified GUID whilst trying to create an event handler.

what 's mean the error infomation and how to fix it :?: , any suggest, please reply me. :idea:

additional, I test this event handle on other Comate samples like Stclock.pb, it works. :?

My flash ocx version is 10.

Posted: Mon Dec 29, 2008 1:38 pm
by srod
Yes there do seem to be reports around the web about ShockwaveFlash not 'sinking' its events properly. COMate requires components to register their events properly within a 'containing' type library and it would appear that Shockwave does not adhere to this requirement.

I have seen c++ code in which custom events are retrieved from flash through a regular message loop retrieving values from various embedded variables etc. but this does not seem appropriate.

As far as I can tell, the "ShockwaveFlash.ShockwaveFlash" class exports 4 events, but since they do not appear to be correctly 'sinked', I do not know how to work with them.
Freak would probably have some idea how to tap into them?

Posted: Mon Dec 29, 2008 3:03 pm
by john lory
thanks for your reply :P

I'll find other solutions for it:)

Posted: Mon Dec 29, 2008 7:59 pm
by Kiffi
john lory wrote:I'll find other solutions for it:)
which ones?

Greetings ... Kiffi

Posted: Mon Dec 29, 2008 9:19 pm
by srod
Okay, I have a workaround which is working fine with swf files. The problem is in how COMate sets about retrieving the connection point for the outgoing interface and that Shockwave supports multiple connection points.

I will investigate a little further, however, as I think there may be a better fix than the one I have right now.

Posted: Mon Dec 29, 2008 10:35 pm
by srod
All fixed. It was indeed a bug with COMate in that I was not enumerating all connection points (and instead just grabbing the first likely looking candidate!)

The following runs fine here with COMate version 1.1.9 for Purebasic 4.3 (I no longer support 4.2). I have tested with several swf files and they all seem to work fine.

I do advise though using COMate_CreateActiveXControl() when trapping events for some ActiveX control or other. Admittedly it doesn't make a fat lot of difference with this example, but it would make things more explicit inmho. :)

Code: Select all

;/////////////////////////////////////////////////////////////////////////////////
;***COMate***  COM automation through iDispatch.
;*===========
;*
;*Flash demo.
;/////////////////////////////////////////////////////////////////////////////////

IncludePath "..\"
XIncludeFile "COMate.pbi"

Procedure myEventCallback(object.COMateObject, eventName.s, parameterCount) 
Debug eventName 
Debug "-----parameterCount---" 
Debug parameterCount
EndProcedure 


Define.COMateObject FlashObject

If OpenWindow(0, #PB_Ignore, #PB_Ignore, 440, 280, "COMate Flash-Demo") 
  
  ContainerGadget(0, 0, 0, 440, 240)
  CloseGadgetList()
  ButtonGadget(1, 20, 250, 60, 25, "Run")
  ButtonGadget(2, 90, 250, 60, 25, "Stop")

  FlashObject = COMate_CreateObject("ShockwaveFlash.ShockwaveFlash", GadgetID(0))

  If FlashObject
    FlashObject\SetEventHandler(@myEventCallback())
    FlashObject\Invoke("LoadMovie(#False, 'c:\worm.swf')")

    Repeat
      result = FlashObject\GetIntegerProperty("ReadyState")
    Until Result = 4

    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
        Case #PB_Event_Gadget
          Select EventGadget()
          Case 1
            FlashObject\Invoke("Play")
            Case 2
              FlashObject\Invoke("Stop")
          EndSelect
      EndSelect
    ForEver
    FlashObject\Release()
  Else
    MessageRequester("COMate -Flash demo", "Couldn't create the ActiveX object!")
  EndIf
EndIf

Posted: Wed Dec 31, 2008 4:39 pm
by john lory
great works~~~~~,thank your great works :P