My Project
Public Types | Public Member Functions | Public Attributes | List of all members
ParaEngine::CFlashPlayer Class Reference

an instance of flash player. More...

#include <FlashTextureManager.h>

Public Types

typedef boost::shared_ptr< boost::thread > Boost_Thread_ptr_type
 

Public Member Functions

 CFlashPlayer (int nFlashPlayerIndex)
 
bool IsFree ()
 whether the current player is free to load a new movie. More...
 
void LoadMovie (const char *filename)
 load a movie by file name, it can be URL, a virtual file, a file, or a resource
 
void PutFlashVars (const char *args)
 put flash variables. More...
 
const char * CallFlashFunction (const char *sFunc)
 [ ActionScript ] import flash.external. More...
 
void SetFlashReturnValue (const char *sResult)
 This function is called from NPL script to set the return value of an NPL function which can be called by the flash external interface call. More...
 
const char * GetFlashReturnValue ()
 get flash return value
 
void UnloadMovie ()
 unload current movie. More...
 
void InvalidateDeviceObjects ()
 release d3d texture. More...
 
void RenderFrameMove (float fCurTime)
 called each render frame move, it may unload time out movies and force flash window to update itself More...
 
bool GetTextureInfo (int *width, int *height)
 get texture info More...
 
LRESULT SendMessage (UINT Msg, WPARAM wParam, LPARAM lParam)
 send a windows message to the inner flash player window. More...
 
LRESULT PostMessage (UINT Msg, WPARAM wParam, LPARAM lParam)
 post a windows message to the inner flash player window. More...
 
const char * GetFileName ()
 get the movie file name. More...
 
int GetIndex ()
 get unique index of this flash player . More...
 
bool IsWindowMode ()
 whether this player is using a real win32 window for display. More...
 
void SetWindowMode (bool bIsWindowMode)
 set whether this player is using a real win32 window for display. More...
 
void MoveWindow (int x, int y, int width, int height, bool bRepaint=true)
 move or resize the window. More...
 
void OnSizeChange ()
 this function is called by ParaEngineApp whenever the window size is changed. More...
 
void SetWindowVisible (bool bVisible)
 show or hide the window. More...
 
void Repaint ()
 repaint all window-mode flash window. More...
 
void SetFocus ()
 this can be called from any thread
 
HWND GetWindowHandle ()
 get the window handle if any. More...
 
void UpdatePixelsBuffer ()
 copy the current flash window client area to a memory buffer in system memory (m_lpPixels). More...
 
HRESULT StartWindowThread ()
 create the default win32 windows for rendering. More...
 
void DefaultWinThreadProc ()
 
bool MsgProcCustom (UINT message, WPARAM wParam, LPARAM lParam)
 process WM_USER messages
 
bool PostWinThreadMessage (UINT message, WPARAM wParam, LPARAM lParam)
 post a WM_USER message to the window thread. More...
 
bool SetParentWindow (HWND hWnd)
 this function is called, whenever the associated main parent window changes. More...
 
bool HasFocus ()
 if the flash window has focus. More...
 
LPDIRECT3DTEXTURE9 GetTexture ()
 get the texture.
 

Public Attributes

string m_filename
 file name that the current texture is associated with.
 
float m_fTimeOut
 if a flash player is never used for this number of time, it will be deleted.
 
float m_fLastUsedTime
 last time the GetTexture() is called.
 
int m_nFlashPlayerIndex
 index of this flash player
 
LPDIRECT3DTEXTURE9 m_pTexture
 dynamic d3d texture
 
D3DFORMAT m_TextureFormat
 
bool m_bUseDynamicTextures
 
bool m_bTextureUpdatedThisFrame
 whether the texture has been update in this rendering frame. More...
 
bool m_bFree
 whether the current player is free.
 
bool m_bTransparent
 There are two modes of rendering are supported: More...
 
HWND m_hwndFlashPlayerControl
 flash control handle
 
int m_nX
 
int m_nY
 
int m_nWidth
 
int m_nHeight
 
int m_nBufWidth
 
int m_nBufHeight
 
int m_nTextureWidth
 
int m_nTextureHeight
 
int m_nWindowX
 
int m_nWindowY
 
int m_nWindowWidth
 
int m_nWindowHeight
 
DWORD * m_lpPixels
 
LinearColor m_backgroundColor
 
bool m_bNeedFlashUpdate
 this flag is set to true every frame move. and set to false when the flash image is saved to temp buffer
 
bool m_bFlipVertical
 
bool m_bWindowMode
 if true, we use a real win32 window. More...
 
string m_sFlashReturnValue
 
Boost_Thread_ptr_type m_win_thread
 
ParaEngine::mutex m_win_thread_mutex
 
bool m_bWindowCreated
 
bool m_bWinThreadMovieLoaded
 
DWORD m_dwWinThreadID
 
string m_sCurrentFlashFunc
 
string m_sCurrentFlashFuncResponse
 
bool m_bInFlashFunc
 
bool m_bHasFocus
 

Detailed Description

an instance of flash player.

Member Function Documentation

§ CallFlashFunction()

const char* ParaEngine::CFlashPlayer::CallFlashFunction ( const char *  sFunc)

[ ActionScript ] import flash.external.

*; ExternalInterface.addCallback("CallMeFromApplication", this, InternalFunction);

function InternalFunction(str: string): string { TextArea1.text = str; return "The function was called successfully"; } [ C++ ] string res = CallFlashFunction("<invoke name=\"CallMeFromApplication" returntype="xml"><arguments><string>Some text for FlashPlayerControl</string></arguments></invoke>");

Parameters
resresult is returned as a string.
Note
: the max return string length of the flash function can not exceed 2048 bytes.
Remarks
: one can also execute NPL script from flash script. Such as below. [ ActionScript ] on (click) { _root.TextArea1.text = flash.external.ExternalInterface.call("SomeNPLFunction(parameters)"); }

Please note that the return value must be explicitly set in the NPL script, by calling SetFlashReturnValue() function. Otherwise empty string is returned.

[Security alert]: must be run in sand-box environment or there is a security here. Plus this function must be called from the same thread as ParaEngine main thread.

§ GetFileName()

const char* ParaEngine::CFlashPlayer::GetFileName ( )

get the movie file name.

§ GetIndex()

int ParaEngine::CFlashPlayer::GetIndex ( )
inline

get unique index of this flash player .

§ GetTextureInfo()

bool ParaEngine::CFlashPlayer::GetTextureInfo ( int *  width,
int *  height 
)

get texture info

Parameters
width[out]
height[out]
Returns

§ GetWindowHandle()

HWND ParaEngine::CFlashPlayer::GetWindowHandle ( )

get the window handle if any.

§ HasFocus()

bool ParaEngine::CFlashPlayer::HasFocus ( )

if the flash window has focus.

§ InvalidateDeviceObjects()

void ParaEngine::CFlashPlayer::InvalidateDeviceObjects ( )

release d3d texture.

§ IsFree()

bool ParaEngine::CFlashPlayer::IsFree ( )
inline

whether the current player is free to load a new movie.

§ IsWindowMode()

bool ParaEngine::CFlashPlayer::IsWindowMode ( )
inline

whether this player is using a real win32 window for display.

§ MoveWindow()

void ParaEngine::CFlashPlayer::MoveWindow ( int  x,
int  y,
int  width,
int  height,
bool  bRepaint = true 
)

move or resize the window.

§ OnSizeChange()

void ParaEngine::CFlashPlayer::OnSizeChange ( )

this function is called by ParaEngineApp whenever the window size is changed.

We usually needs to reposition all flash windows according to the new size.

§ PostMessage()

LRESULT ParaEngine::CFlashPlayer::PostMessage ( UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

post a windows message to the inner flash player window.

in most cases: we will forward mouse and key messages to the flash player using this function.

§ PostWinThreadMessage()

bool ParaEngine::CFlashPlayer::PostWinThreadMessage ( UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

post a WM_USER message to the window thread.

§ PutFlashVars()

void ParaEngine::CFlashPlayer::PutFlashVars ( const char *  args)

put flash variables.

This function must be loaded before a flash movie is loaded.

Parameters
argssuch as "company=http://paraengine.com"

§ RenderFrameMove()

void ParaEngine::CFlashPlayer::RenderFrameMove ( float  fCurTime)

called each render frame move, it may unload time out movies and force flash window to update itself

Parameters
fCurTimeElapsed Time in seconds

§ Repaint()

void ParaEngine::CFlashPlayer::Repaint ( )

repaint all window-mode flash window.

in case of full screen render, we may need to repaint when the background scene finished.

§ SendMessage()

LRESULT ParaEngine::CFlashPlayer::SendMessage ( UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

send a windows message to the inner flash player window.

in most cases: we will forward mouse and key messages to the flash player using this function.

§ SetFlashReturnValue()

void ParaEngine::CFlashPlayer::SetFlashReturnValue ( const char *  sResult)

This function is called from NPL script to set the return value of an NPL function which can be called by the flash external interface call.

Parameters
sResultxml encoded string. such as "<string>Result from NPL</string>". if NULL, it is set to "<string></string>"

§ SetParentWindow()

bool ParaEngine::CFlashPlayer::SetParentWindow ( HWND  hWnd)

this function is called, whenever the associated main parent window changes.

Internally, we just call win32 function SetParent to change any already created flash windows.

§ SetWindowMode()

void ParaEngine::CFlashPlayer::SetWindowMode ( bool  bIsWindowMode)

set whether this player is using a real win32 window for display.

Default to false.

§ SetWindowVisible()

void ParaEngine::CFlashPlayer::SetWindowVisible ( bool  bVisible)

show or hide the window.

§ StartWindowThread()

HRESULT ParaEngine::CFlashPlayer::StartWindowThread ( )

create the default win32 windows for rendering.

and assigning to m_hWnd. window is created in another thread. Since windows uses single threaded apartment, the window procedure should also be in that thread.

§ UnloadMovie()

void ParaEngine::CFlashPlayer::UnloadMovie ( )

unload current movie.

However d3d texture and the flash player window are not released for reuse.

§ UpdatePixelsBuffer()

void ParaEngine::CFlashPlayer::UpdatePixelsBuffer ( )

copy the current flash window client area to a memory buffer in system memory (m_lpPixels).

One may need to call Repaint() prior to this call to force flash window to update itself first.

Member Data Documentation

§ m_bTextureUpdatedThisFrame

bool ParaEngine::CFlashPlayer::m_bTextureUpdatedThisFrame

whether the texture has been update in this rendering frame.

if there are multiple calls to GetTexture() in the same rendering frame, we will only copy texture once.

§ m_bTransparent

bool ParaEngine::CFlashPlayer::m_bTransparent

There are two modes of rendering are supported:

  1. Full transparent mode. In this mode, you get pixel colors with alpha component. You can create a texture with alpha channel.
  2. Simple transparent mode. In this mode, real value of alpha channel is not available. But this mode faster than full transparent mode.
    Yes if you want to see how full transparent mode works. No if you want to see how simple transparent mode works.

§ m_bWindowMode

bool ParaEngine::CFlashPlayer::m_bWindowMode

if true, we use a real win32 window.


The documentation for this class was generated from the following file: