FPCN_LOADEXTERNALRESOURCE
Syntax
FPCN_LOADEXTERNALRESOURCE
struct SFPCLoadExternalResource
{
NMHDR hdr;
LPCTSTR lpszRelativePath; // requested relative path
LPSTREAM lpStream; // stream to write resource data
};
Description
The FPCN_LOADEXTERNALRESOURCE
notification is sent when a Flash movie (loaded from memory) attempts to load an external resource such as XML, JPEG, MP3, etc., using a relative path.
The application can intercept this request and provide the resource data by writing it into the supplied lpStream
.
This mechanism allows embedding and secure delivery of resources without relying on the file system.
Example
For instance, if a movie loads an image using ActionScript:
loadMovie("images/external_image.jpg", "square");
You can provide the content by handling the FPCN_LOADEXTERNALRESOURCE
notification:
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_NOTIFY:
{
NMHDR* pNMHDR = (NMHDR*)lParam;
if (pNMHDR->hwndFrom == g_hwndFlashPlayerControl)
{
switch (pNMHDR->code)
{
case FPCN_LOADEXTERNALRESOURCE:
{
SFPCLoadExternalResource* pInfo = (SFPCLoadExternalResource*)lParam;
if (0 == lstrcmpi(pInfo->lpszRelativePath, _T("images/external_image.jpg")))
{
HMODULE hModule = GetModuleHandle(NULL);
HRSRC hResInfo = FindResource(hModule, _T("IMAGE1"), _T("JPEG"));
HGLOBAL hResData = LoadResource(hModule, hResInfo);
LPVOID lpResourceData = LockResource(hResData);
DWORD dwResourceSize = SizeofResource(hModule, hResInfo);
ULONG ulWritten;
pInfo->lpStream->Write(lpResourceData, dwResourceSize, &ulWritten);
}
break;
}
}
}
break;
}
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}