Use Components in the AIR Application

This example shows how to use the viewer and designer components in the AIR applications. You can use the components and their classes as well as in Flex application, they are fully compatible. The difference is only in the type of the project:

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
initialize="onInitialize()"
showStatusBar="false" backgroundColor="#e8e8e8" width="900" height="600">


private var reportString: String;

private function onInitialize(): void
{
StiViewerFx.initialize();
StiDesignerFx.initialize();

var request: URLRequest = new URLRequest(demoFile);
var loader: URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoadComplete);
loader.load(request);
}

private function onLoadComplete(event: Event): void
{
var loader: URLLoader = event.target as URLLoader;
reportString = loader.data as String;
}

private function onViewReportClick(): void
{
// Create new report object
var report: StiReport = new StiReport();
// Load report from XML string
report.loadReportFromString(reportString);
// Show report in Viewer dialog window
report.showDialog();
}

private function onDesignReportClick(): void
{
// Create new report object
var report: StiReport = new StiReport();
// Load report from XML string
report.loadReportFromString(reportString);
// Design report in dialog window
report.designDialog();
}


In the screenshot below you can see the result of the sample code.

Use Components in the AIR Application