FunctionHandler

FunctionHandler
Scaleform::GFx::FunctionHandler
Declaration
class FunctionHandler : public RefCountBase<FunctionHandler, Stat_Default_Mem>;
Description

FunctionHandler allows the creation of C++ callbacks that behave like any ActionScript2 Virtual Machine function. By using Movie::CreateFunction, users can create AS2 function objects that can be assigned to any variable in the VM. This function object can be invoked from within the VM, and the invokation will be reported via the Call method. 

The following example sets a custom function object to a member of an AS2 VM object located at '_root.obj':

   Value obj;
   pmovie->GetVariable(&obj, "_root.obj");
   class MyFunc : public FunctionHandler
   {
      public:
      virtual void Call(const Params& params)
      {
         SF_UNUSED(params);
         printf("> MY FUNCTION CALLED (Call)\n");
      }
   };
   Ptr<MyFunc> customFunc = *SF_HEAP_NEW(Memory::GetGlobalHeap()) MyFunc();
   Value func, func2;
   pmovie->CreateFunction(&func, customFunc);
   obj.SetMember("func", func);

In ActionScript, the customFunc::Call method can be triggered by simply invoking the AS2 function object:

   obj.func(param1, param2, ...);

NOTE: If a user defined FunctionHandler instance has a Value member that is holding a reference to an AS2 VM Object (Object, Array, MovieClip, etc.) then it MUST be cleaned up by the user before the movie root dies. This can be achieved by calling Value::SetUndefined(); on the member.

Methods
Method 
Description 
Call 
Callback method of a function context that is invoked when the function object wrapping the context is invoked in the AS2 VM. 
Structures
Structure 
Description 
Structure listing the parameters passed in to the callback from the AS2 VM. 
File

GFx_Player.h