Flash External API

F-IN-BOX supports the Flash External API, allowing an application to call ActionScript functions within a Flash movie and enabling the movie to access data from the application synchronously (unlike using fscommand).


Calling an ActionScript Function from an Application

First, register your function using ExternalInterface.addCallback:

import flash.external.*;
 
ExternalInterface.addCallback("CallMeFromApplication", this, InternalFunction);
 
function InternalFunction(str: String): String {
    TextArea1.text = str;
    return "The function was called successfully";
}

Then call the registered ActionScript function from your application using CallFunction:

C# Example

string Response =
    f_in_box__control1.FlashMethod_CallFunction(
        "<invoke name=\"CallMeFromApplication\" returntype=\"xml\">" +
        "<arguments><string>Some text for F-IN-BOX.NET</string></arguments></invoke>"
    );
 
MessageBox.Show("The function returned: '" + Response + "'");

VB.NET Example

Dim Response As String = _
    f_in_box__control1.FlashMethod_CallFunction( _
        "<invoke name=\"CallMeFromApplication\" returntype=\"xml\">" & _
        "<arguments><string>Some text for F-IN-BOX.NET</string></arguments></invoke>")
 
MsgBox("The function returned: '" & Response & "'")

Calling an Application Function from Flash

In your Flash script, use flash.external.ExternalInterface.call:

on (click) {
    _root.TextArea1.text = flash.external.ExternalInterface.call("SomeFunction");
}

Handle the OnFlashCall event in your application:

C# Example

private void f_in_box__control1_OnFlashCall(object sender, string request)
{
    f_in_box__control1.FlashMethod_SetReturnValue(
        "Current time is: " + System.DateTime.Now.ToString()
    );
}

VB.NET Example

Private Sub f_in_box__control1_OnFlashCall( _
    ByVal sender As Object, _
    ByVal request As String) Handles f_in_box__control1.OnFlashCall
 
    f_in_box__control1.FlashMethod_SetReturnValue( _
        "Current time is: " & System.DateTime.Now.ToString())
End Sub

This approach provides two-way communication between Flash content and the hosting application, enabling advanced interactivity without relying on fscommand.