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

Just starting out? Need help? Post your questions and find answers here.
john lory
User
User
Posts: 10
Joined: Mon Dec 29, 2008 10:24 am
Location: web

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

Post 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.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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?
I may look like a mule, but I'm not a complete ass.
john lory
User
User
Posts: 10
Joined: Mon Dec 29, 2008 10:24 am
Location: web

Post by john lory »

thanks for your reply :P

I'll find other solutions for it:)
User avatar
Kiffi
Addict
Addict
Posts: 1504
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

john lory wrote:I'll find other solutions for it:)
which ones?

Greetings ... Kiffi
Hygge
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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
I may look like a mule, but I'm not a complete ass.
john lory
User
User
Posts: 10
Joined: Mon Dec 29, 2008 10:24 am
Location: web

Post by john lory »

great works~~~~~,thank your great works :P
Post Reply