Jump to content

Flex ExternalInterface call and AutoIT


iDenoQ
 Share

Recommended Posts

I am having problems communicating to and from Flash with AutoIT. I have embedded SWF which is working perfectly but no communication from Flash to AutoIT, and when I try to call Flash from AutoIT I receive 80020009 COM error... My problems may be platform specific: Win7x64, flash player 10.

I am sure that these methods were working before. I am interested if anybody has tried lately to embed flash and communicate with it.

I have searched web and forums and I couldn't find solution.

Link to comment
Share on other sites

Right. What I have discovered is:

1. If I call objectflash.CallFunction before Flex framework is loaded ExternalInterface never gets exposed to AutoIT and I receive undefined 80020009 COM error.

2. If I make button with objectflash.CallFunction and wait for Flex application to load in embedded player, and then click it - function call is working AutoIT->Flex.

3. Calling function from Flex to AutoIT is never fired, no response, nothing. If I try to register ObjEvent at anytime - I don't get any response, function is never called.

Here is the code:

#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
  FLEX <--> AUTOIT
#ce ----------------------------------------------------------------------------
; Options
Opt("GUIOnEventMode", 1)
Opt( "TrayMenuMode", 3 )
AutoItSetOption ( "WinSearchChildren", 0 )
_Singleton("FLEXAU3A-B5D6-11E0-B31A-4EA04824019B")
_runOnlyCompiled()
; Includes
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>
#include <Misc.au3>
; Tray menu
Local $flashitem = TrayCreateItem("Call Flash")
Local $exititem = TrayCreateItem("Exit")
TraySetState()
; Shockwave Object
Global $oSWF = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")
Global $g_eventerror = 0
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
Global $SinkObject = ObjEvent( $oSWF, 'swf_' )
; Main GUI
$MG = GUICreate( "SWF Interface", 600, 430, -1, -1, $WS_DLGFRAME )
$oSWF_Object = GUICtrlCreateObj ( $oSWF, 0, 0, 600, 430 )
GUICtrlSetStyle ( $oSWF_Object,  $WS_VISIBLE )
With $oSWF
  .Movie = @ScriptDir & "\autoitgui.swf"
  .ScaleMode = 3
  .bgcolor = "C3DDFE"
  .Loop = True
  .WMode = "opaque"
  .allowScriptAccess = "Always"
  .Quality = 1
  .Playing = 1
  .Menu = 1
EndWith
GUISetState( @SW_SHOW, $MG )
; Main loop
While 1
$msg = GUIGetMsg()
Select
  Case $msg = $GUI_EVENT_CLOSE
   ; no close
EndSelect
Local $mssg = TrayGetMsg()
Select
  Case $mssg = 0
   ContinueLoop
  Case $mssg = $exititem
   ExitLoop
  Case $mssg = $flashitem
   $oSwf.CallFunction('<invoke name="hideMC"><arguments><string></string></arguments></invoke>')
   ; ObjEvent( $oSWF, 'swf_' )
EndSelect
WEnd
Exit
 

#cs --------------------------------
  FUNCTIONS
#ce --------------------------------
; Called from Flex like this
;
; if ( ! ExternalInterface.available)
; {
;  Alert.show( "No external interface available..." );
; }
; else
; {
;  ExternalInterface.call( "flexcall", "<string>Hello AutoIT</string>" );
; }
;
Func swf_flexcall( $params )
MsgBox( 0, "YEAH", "Executed ffff" )
EndFunc
Func _runOnlyCompiled()
If @compiled = 0 Then
  MsgBox( 0, "ERROR", "Sorry, run EXE not AU3!" )
  Exit
EndIf
EndFunc
Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"     & @CRLF  & @CRLF & _
    "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
    "err.windescription:"    & @TAB & $oMyError.windescription & @CRLF & _
    "err.number is: "        & @TAB & $HexNumber              & @CRLF & _
    "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
    "err.scriptline is: "    & @TAB & $oMyError.scriptline   & @CRLF & _
    "err.source is: "        & @TAB & $oMyError.source       & @CRLF & _
    "err.helpfile is: "    & @TAB & $oMyError.helpfile     & @CRLF & _
    "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
   )
  SetError(1)
Endfunc

I will do the same in C# today and compile Form with Flex to see what happens. I will report here after.

Link to comment
Share on other sites

Finally I decided to use C# to create form using "Interop.ShockwaveFlashObjects.dll" and "AxInterop.ShockwaveFlashObjects.dll" (you can generate them from flash ocx using .net) and then use that form in my AutoIT project. If anybody is interested I can post or attach code.

The main reason for doing all this was to achieve more flexible interface. Flex was perfect for this task.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...