F-IN-BOX supports External API. You can call functions of a movie and a movie is able to get data from an application synchronously (instead of fscommand).
Register your function using ExternalInterface.addCallback:
[ ActionScript ]
- import flash.external.*;
-
- ExternalInterface.addCallback("CallMeFromApplication", this, InternalFunction);
-
- function InternalFunction(str: String): String {
- TextArea1.text = str;
-
- return "The function was called successfully";
- }
import flash.external.*;
ExternalInterface.addCallback("CallMeFromApplication", this, InternalFunction);
function InternalFunction(str: String): String {
TextArea1.text = str;
return "The function was called successfully";
}
Use function FPCCallFunction or FPCCallFunctionBSTR:
[ C++ ]
- TCHAR szResponse[1024] = { 0 };
-
- DWORD dwLength = sizeof(szResponse) / sizeof(szResponse[0]) - 1;
-
- FPCCallFunction(m_hwndFlashPlayerControl,
-
- _T("<invoke name=\"CallMeFromApplication\" returntype=\"xml\"><arguments><string>Some text for FlashPlayerControl</string></arguments></invoke>"),
-
- szResponse,
-
- &dwLength);
-
- AfxMessageBox(CString(_T("The function returned: ")) + szResponse);
TCHAR szResponse[1024] = { 0 };
DWORD dwLength = sizeof(szResponse) / sizeof(szResponse[0]) - 1;
FPCCallFunction(m_hwndFlashPlayerControl,
_T("<invoke name=\"CallMeFromApplication\" returntype=\"xml\"><arguments><string>Some text for FlashPlayerControl</string></arguments></invoke>"),
szResponse,
&dwLength);
AfxMessageBox(CString(_T("The function returned: ")) + szResponse);
[ C++ ]
- BSTR bstrRequest = SysAllocString(L"<invoke name="\"CallMeFromApplication\"" returntype="\"xml\""><arguments><string>Some text for FlashPlayerControl</string></arguments></invoke>");
-
- BSTR bstrResponse;
-
- if (S_OK ==
- FPCCallFunctionBSTR(m_hwndFlashPlayerControl,
- bstrRequest,
- &bstrResponse))
- {
- USES_CONVERSION;
-
- CString str = OLE2T(bstrResponse);
-
- AfxMessageBox(CString(_T("The function returned: ")) + str);
-
- SysFreeString(bstrResponse);
- }
-
- SysFreeString(bstrRequest);
BSTR bstrRequest = SysAllocString(L"Some text for FlashPlayerControl");
BSTR bstrResponse;
if (S_OK ==
FPCCallFunctionBSTR(m_hwndFlashPlayerControl,
bstrRequest,
&bstrResponse))
{
USES_CONVERSION;
CString str = OLE2T(bstrResponse);
AfxMessageBox(CString(_T("The function returned: ")) + str);
SysFreeString(bstrResponse);
}
SysFreeString(bstrRequest);
Use flash.external.ExternalInterface.call:
[ ActionScript ]
- on (click) {
- _root.TextArea1.text = flash.external.ExternalInterface.call("SomeFunction");
- }
on (click) {
_root.TextArea1.text = flash.external.ExternalInterface.call("SomeFunction");
}
Handle notification FPCN_FLASHCALL:
[ C++ ]
- <div class="code">
- LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- if (WM_NOTIFY == message)
- {
- LPNMHDR lpNMHDR = (LPNMHDR)lParam;
-
- if (m_hwndFlashPlayerControl == lpNMHDR->hwndFrom)
- switch (lpNMHDR->code)
- {
- case FPCN_FLASHCALL:
- {
- SFPCFlashCallInfoStruct* pInfo = (SFPCFlashCallInfoStruct*)lParam;
-
- CString str;
- str += _T("The request is: '");
- str += pInfo->request;
- str += _T("'");
-
- AfxMessageBox(str);
-
- COleDateTime now = COleDateTime::GetCurrentTime();
- FPCSetReturnValue(m_hwndFlashPlayerControl,
- _T("<string>Current time is: ") +
- now.Format() +
- _T("\r\nThis info is returned from the handler</string>"));
-
- return 1;
- }
- }
- ...
- }
- </div>
LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (WM_NOTIFY == message)
{
LPNMHDR lpNMHDR = (LPNMHDR)lParam;
if (m_hwndFlashPlayerControl == lpNMHDR->hwndFrom)
switch (lpNMHDR->code)
{
case FPCN_FLASHCALL:
{
SFPCFlashCallInfoStruct* pInfo = (SFPCFlashCallInfoStruct*)lParam;
CString str;
str += _T("The request is: '");
str += pInfo->request;
str += _T("'");
AfxMessageBox(str);
COleDateTime now = COleDateTime::GetCurrentTime();
FPCSetReturnValue(m_hwndFlashPlayerControl,
_T("<string>Current time is: ") +
now.Format() +
_T("\r\nThis info is returned from the handler</string>"));
return 1;
}
}
...
}
Copyright © Softanics. All rights reserved.
F-IN-BOX is a trademark of Softanics.
Macromedia and Shockwave Flash are trademarks of Adobe