Capture Flash / ActionScript Events

Add-in Express™ Support Service
That's what is more important than anything else

Capture Flash / ActionScript Events
 
Robert Stanley




Posts: 9
Joined: 2012-05-24
Hello,

I'm trying to capture data fr om my Flash application written in ActionScript to my toolbar. I'm trying to display the copied text in the toolbar. I did a POC wh ere I was able to copy text off a non-Flash web page and was able to display the text in the toolbar, but when I have my Flash application copy text to the clipboard the toolbar events never fire. I know the text was copied to the clipboard because I can then paste it. How do I get my Flash application to fire the toolbar events? Is there a better way to get text from my Flash application to my toolbar, if so help!
Posted 22 Jun, 2012 15:57:44 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Robert,

Do you have any clipboard events in the Flash application?
If so, you can access the toolbar code from javascript directly. You just need to initialize a javascript variable in the toolbar code.
E.g.
private void IEModule_DownloadComplete()
{
try
{
object scriptEngine = HTMLDocument.Script;
if (scriptEngine != null)
{
scriptEngine.GetType().InvokeMember("bhoModule", BindingFlags.SetProperty, null, scriptEngine, new object[] { this } );
}
}
catch
{
}
}

Then you can call public methods of your toolbar via the 'bhoModule' variable (e.g. 'bhoModule.MyMethod();' ).
Posted 25 Jun, 2012 04:06:37 Top
Robert Stanley




Posts: 9
Joined: 2012-05-24
So I can put javascript code on my flash page that I can call. What would be the best method to call for the toolbar so I can send text to it?
Posted 26 Jun, 2012 10:58:25 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Robert,

The C# public method would look like below:

private const int WM_USER = 0x0400;
private const int WM_UPDATE_TEXT = WM_USER + 100;
private string clipboardText = null;

public void UpdateText(string text)
{
clipboardText = text;
SendMessage(WM_UPDATE_TEXT, IntPtr.Zero, IntPtr.Zero);
}

private void IEModule_OnSendMessage(ADXIESendMessageEventArgs e)
{
if (e.Message == WM_UPDATE_TEXT)
{
textBox.Text = clipboardText;
}
}

In javascript, it will be something like 'bhoModule.UpdateText("My text");'.
Posted 26 Jun, 2012 12:41:46 Top