FlashCallAction: String;
FlashCallAction: string;
The FlashCallAction property determines a handler of FlashCall events for a Flash movie.
An SWF movie must use ExternalInterface to use the handler. A Flash object does not require any preparatory work and can be a random object.
Macros implemented in classes cannot be used as handlers. Depending on the file where the macro is implemented, the path to the macro in this property is specified in the different ways:
The macro is implemented in a unit or form of the repository: <Unit or form ID>.<Macro ID>.
The macro is implemented in an object of the repository assembly: <Assembly ID>.<Macro ID>.
In the units and forms of the repository user macros should be implemented in the Global Scope of names.
To execute the following example, create a unit with the Module identifier (the FlashCall and SelectDeselectEl procedures, link the Ui, Tab, Dimensions, and Report assemblies), which will handle the event:
Public Sub FlashCall(Flash: IPrxFlash; Args: IPrxFlashCallEventArgs);
Var
i, j, iEl: integer;
a: Array;
Begin
If Args.Arguments <> Null Then
For i := 0 To Args.Arguments.Length - 1 Do
If Args.Arguments[i] Is array Then
a := Args.Arguments[i] As array;
For j := 0 To a.Length - 1 Do
If ((a[j] As String) <> "<undefined/>") Then
iEl := Args.Arguments[j] As Integer;
End If;
End For;
Else
If ((Args.Arguments[i] As String) <> "<undefined/>") Then
iEl := Args.Arguments[i] As Integer;
End If;
End If;
End For;
End If;
SelectDeselectEl(iEl);
End Sub FlashCall;
Public Sub SelectDeselectEl(i: integer); //selecting or deselecting the i-th element of the dictionary
Var
Sel: IDimSelection;
id: integer; //Element index in the dictionary
Begin
Sel := PrxReport.ActiveReport.Controls.Item(0).Dimension.Selection;
id := Sel.Dimension.Elements.FindById(i.ToString); //find element index by ID
If (Sel.IsElementSelected(id)) Then
sel.DeselectElement(id, False);
Else
sel.SelectElement(id, False);
End If;
If (Prxreport.ActiveReport.DataIslands.Item(0) <> Null) Then
Prxreport.ActiveReport.DataIslands.Item(0).Recalc;
End If;
End Sub SelectDeselectEl;
Then create a regular report with the Report identifier and add the created unit to report units. Place the Flash object, which uses FlashMapEngine.swf movie, on a report sheet. Define initialization string for the Flash object, this initialization string should have disabled option of passing events via onFsCommand (fscomand='0') and should not define the onClick attribute. Add a data source containing a territory dictionary to the report, and create a control. Create a data source slice and place it to the sheet. Add links to the Metabase, Report, Tab system assemblies in the unit.
Sub UserProc;
Var
MB: IMetabase;
Report: IPrxReport;
Tab: ITabSheet;
Flash: IPrxFlash;
Begin
MB := MetabaseClass.Active;
Report := MB.ItemById("Report").Edit As IPrxReport;
Tab := (Report.Sheets.Item(0) As IPrxTable).TabSheet;
Flash := Tab.Objects.Item(0).Extension As IPrxFlash;
Flash.FlashCallAction := "Module.FlashCall";
(Report As IMetabaseObject).Save;
End Sub UserProc;
After executing the example an event handler is assigned to the Flash object. Clicking a map region inverts selection in the control. For example, clicking the Belgorod region selects or deselects the Belgorod Region element in the territory dictionary. When the selection changes, the data area is calculated. To provide correct selection, region identifiers in the topobase should match region identifiers in the dictionary.
Create a unit with the Module identifier (the FlashCall and SelectDeselectEl procedures) described in the example above. Fore.NET event handlers are not supported, as user macros in .NET units and .NET forms are described within a class.
Then create a regular report with the Report identifier and add the created unit to report units. Place the Flash object, which uses FlashMapEngine.swf movie, on a report page. Define initialization string for the Flash object, this initialization string should have disabled option of passing events via onFsCommand (fscomand='0') and should not define the onClick attribute. Add a data source containing a territory dictionary to the report, and create a control. Create a data source slice and place data area to the sheet.
The specified example is an entry point for a .NET assembly. Add links to the Metabase, Report, Tab system assemblies in the unit.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Tab;
Imports Prognoz.Platform.Interop.Report;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Report: IPrxReport;
Tab: ITabSheet;
Flash: IPrxFlash;
Begin
MB := Params.Metabase;
Report := MB.ItemById["Report"].Edit() As IPrxReport;
Tab := (Report.Sheets.Item[0] As IPrxTable).TabSheet;
Flash := Tab.Objects.Item[0].Extension As IPrxFlash;
Flash.FlashCallAction := "Module.FlashCall";
(Report As IMetabaseObject).Save();
End Sub;
After executing the example an event handler is assigned to the Flash object. Clicking a map region inverts selection in the control. For example, clicking on Belgorod region selects or deselects the Belgorod Region element in the territory dictionary. When the selection changes, the data area is calculated. To provide correct selection, region identifiers in the topobase should match region identifiers in the dictionary.
See also: