Jump to content

Flex ExternalInterface call and AutoIT

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.

Share this post

Link to post
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:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
#ce ----------------------------------------------------------------------------
; Options
Opt("GUIOnEventMode", 1)
Opt( "TrayMenuMode", 3 )
AutoItSetOption ( "WinSearchChildren", 0 )
; 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")
; 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
GUISetState( @SW_SHOW, $MG )
; Main loop
While 1
$msg = GUIGetMsg()
  Case $msg = $GUI_EVENT_CLOSE
   ; no close
Local $mssg = TrayGetMsg()
  Case $mssg = 0
  Case $mssg = $exititem
  Case $mssg = $flashitem
   $oSwf.CallFunction('<invoke name="hideMC"><arguments><string></string></arguments></invoke>')
   ; ObjEvent( $oSWF, 'swf_' )

#cs --------------------------------
#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" )
Func _runOnlyCompiled()
If @compiled = 0 Then
  MsgBox( 0, "ERROR", "Sorry, run EXE not AU3!" )
Func MyErrFunc()
  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 _

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

Share this post

Link to post
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.

Share this post

Link to post
Share on other sites

I have succeeded creating what I want in C#, now I will go back to AutoIT and try to achieve the same. If I do I promise to post everything on this great community code examples page.

Share this post

Link to post
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


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.