Get ActionScript Variable error

DLL Edition of the F-IN-BOX
Abelorn
Posts: 7
Joined: Wed Dec 08, 2010 11:26 am

Get ActionScript Variable error

Postby Abelorn » Wed Dec 08, 2010 4:52 pm

in first 5 variants of calling below i get MEGA-ERROR, and 6th allways returns emptyness as a result no matter how non-existant or real variable i ask it for. ( tried all 6 and even all of them without "_T()" , wasn't sure what to use and what would work - none worked anyway)

calling with a button:

Code: Select all

void CSample01_SWF_And_FLV_PlayerDlg::InvokeGetMyVariable()
{
   //InvokeGetVariable(m_hwndFlashPlayerControl, _T("MyArray"));
   //InvokeTGetProperty(m_hwndFlashPlayerControl, _T("MyArray"), 0);
   //InvokeTGetProperty(m_hwndFlashPlayerControl, _T("MyArray"), 1);
   //InvokeTGetPropertyAsNumber(m_hwndFlashPlayerControl, _T("MyArray"), 0);
   //InvokeTGetPropertyAsNumber(m_hwndFlashPlayerControl, _T("MyArray"), 1);
   GetFlashVars(m_hwndFlashPlayerControl, _T("MyArray"));
}


code taken from your help section

Code: Select all

void InvokeGetVariable(HWND hwndFlashPlayerControl, LPCTSTR name) 

   SFPCGetVariable info; 
   
   
   info.name.lpszBuffer = name; 
   
   
   info.Result.lpszBuffer = NULL; 
 
   ::SendMessage(hwndFlashPlayerControl, FPCM_GETVARIABLE, 0, (LPARAM)&info); 
 
   if FAILED(info.hr) 
      // Error 
   { 
      ::MessageBox(NULL, info.Result.lpszBuffer, _T("MEGA-ERROR"), MB_OK);
      return; 
   } 
 
   info.Result.lpszBuffer = (TCHAR*)LocalAlloc(LPTR, info.Result.dwBufferSize * sizeof(TCHAR)); 
 
   ::SendMessage(hwndFlashPlayerControl, FPCM_GETVARIABLE, 0, (LPARAM)&info); 
 
 
   if FAILED(info.hr) 
      // Error 
   { 
       ::MessageBox(NULL, info.Result.lpszBuffer, _T("ERROR"), MB_OK); 
   } 
   else 
      // OK 
   { 
      ::MessageBox(NULL, info.Result.lpszBuffer, _T("Result"), MB_OK); 
   } 
 
   LocalFree((HLOCAL)info.Result.lpszBuffer); 


void InvokeTGetProperty(HWND hwndFlashPlayerControl, LPCTSTR target, int property) 

   SFPCTGetProperty info; 


   info.target.lpszBuffer = target; 

   info.property = property; 


   info.Result.lpszBuffer = NULL; 

   ::SendMessage(hwndFlashPlayerControl, FPCM_TGETPROPERTY, 0, (LPARAM)&info); 

   if FAILED(info.hr) 
      // Error 
   { 
      ::MessageBox(NULL, info.Result.lpszBuffer, _T("MEGA-ERROR"), MB_OK); 
      return; 
   } 

   info.Result.lpszBuffer = (TCHAR*)LocalAlloc(LPTR, info.Result.dwBufferSize * sizeof(TCHAR)); 

   ::SendMessage(hwndFlashPlayerControl, FPCM_TGETPROPERTY, 0, (LPARAM)&info); 


   if FAILED(info.hr) 
      // Error 
   { 
      ::MessageBox(NULL, info.Result.lpszBuffer, _T("ERROR"), MB_OK); 
   } 
   else 
      // OK 
   { 
      ::MessageBox(NULL, info.Result.lpszBuffer, _T("Result"), MB_OK); 
   } 

   LocalFree((HLOCAL)info.Result.lpszBuffer); 


void GetFlashVars(HWND hwndFlashPlayerControl, LPSTR FlashVars) 

   SFPCGetFlashVars info; 
 
   info.lpszBuffer = FlashVars; 
 
   ::SendMessage(hwndFlashPlayerControl, FPCM_GET_FLASHVARS, 0, (LPARAM)&info); 
 
   if FAILED(info.hr) 
      // Error 
   { 
      ::MessageBox(NULL, NULL, _T("MEGA-ERROR"), MB_OK); 
      return; 
   } 
 
   info.lpszBuffer = (TCHAR*)LocalAlloc(LPTR, info.dwBufferSize * sizeof(TCHAR)); 
 
   ::SendMessage(hwndFlashPlayerControl, FPCM_GET_FLASHVARS, 0, (LPARAM)&info); 
 
   if FAILED(info.hr) 
      // Error 
   { 
      ::MessageBox(NULL, NULL, _T("ERROR"), MB_OK); 
   } 
   else 
      // OK 
   { 
      ::MessageBox(NULL, info.lpszBuffer, _T("Result"), MB_OK); 
   } 
 
   LocalFree((HLOCAL)info.lpszBuffer); 
}

void InvokeTGetPropertyAsNumber(HWND hwndFlashPlayerControl, LPCTSTR target, int property)
{
   SFPCTGetPropertyAsNumber info;


   info.target.lpszBuffer = target;

   info.property = property;

   
    ::SendMessage(hwndFlashPlayerControl, FPCM_TGETPROPERTYASNUMBER, 0, (LPARAM)&info);
   
   
    if FAILED(info.hr)
    // Error
    {
      ::MessageBox(NULL, NULL, _T("MEGA-ERROR"), MB_OK);
    }
    else
      // OK
    {
    TCHAR lpszBuffer[1024];
   
    wsprintf(lpszBuffer, _T("%d"), info.Result);
   
    ::MessageBox(NULL, lpszBuffer, _T("Result"), MB_OK);
    }
 }



MyArray is a global variable in my .swf file initialised in frame1.


Code: Select all

public var MyArray:Array;


how can i get it in my C++ application?

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Wed Dec 08, 2010 6:01 pm

Thank you for your question.

I'm not sure that it's possible to obtain value of such variable.

Could you please for test add this code to your movie:

Code: Select all

_root.Test = "1";


and try to get it from C++:

Code: Select all

TCHAR lpszBuffer[256] = { 0 };
DWORD dwBufferSize = DEF_ARRAY_SIZE(lpszBuffer);
FPC_GetVariable(m_hFlashWnd, _T("_root.Test"), lpszBuffer, &dwBufferSize);


?

Thank you.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

Abelorn
Posts: 7
Joined: Wed Dec 08, 2010 11:26 am

Postby Abelorn » Wed Dec 08, 2010 6:18 pm

Softanics wrote:Thank you for your question.

I'm not sure that it's possible to obtain value of such variable.

or at least change it, is it possible?


Softanics wrote:Could you please for test add this code to your movie:

sorry, can't. It doesn't compile if I add it :oops:

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Wed Dec 08, 2010 6:41 pm

Abelorn wrote:or at least change it, is it possible?


You can add a function that changes it and call this function using external api:

http://www.f-in-box.com/dll/help/index/ ... l_api.html
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

Abelorn
Posts: 7
Joined: Wed Dec 08, 2010 11:26 am

Postby Abelorn » Fri Dec 10, 2010 9:12 pm

ok, but without ExternalInterface, you have tested flash.ocx things to work before you overlap it with f-in-box, no?

so how do you make GetVariable() work?

Code: Select all

?package
{
    import flash.text.*;
    ...

    public class MyClass extends MovieClip
    {
        public var MyString:String = "Hello World!";
        ...

how to get MyString from MyClass with your GetVariable()?

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Mon Dec 13, 2010 1:29 pm

Hello,

Abelorn wrote:ok, but without ExternalInterface, you have tested flash.ocx things to work before you overlap it with f-in-box, no?


Yes, we tested but with AS2. It seems that you use AS3, and I'm not sure that GetVariable() can work with AS3.

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html


Return to “DLL Edition”

Who is online

Users browsing this forum: No registered users and 9 guests

cron