Skip navigation
Currently Being Moderated

How to Call a AIR application from Flex Application

Sep 24, 2009 2:55 AM

Hi,

 

    I have Used AIR (Desktop application) in Flex Builder to Upload a File from a local path and save it it a server path.

 

I need to Call this AIR(Desktop application) from my Flex Application.... i.e

I am using a link button to send a event using Script and Forward that Desktop application  from Flex Screen

 

But it doesnot load that (Desktop application)  in Screen. Only Balnk screen is loaded from path

 

Here is the code

AIR(Desktop application)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<?xml version="1.0" encoding="utf-8"?>

<mx:WindowedApplication

 

 

xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="openBrowseWindow();"

>

 

 

<mx:HTTPService id="urlpath" showBusyCursor="true" useProxy="false

"

method="

 

POST" url="http://localhost:8080/nat/FlexAction.do?method=UrlPath

"

result="pathresult(event)"

fault="faultHandler(event)"

 

>

 

</mx:HTTPService>

 

 

 

<mx:Script>

<![CDATA[

 

 

import

mx.events.FileEvent;

 

 

import

mx.rpc.events.ResultEvent;

 

 

import

mx.rpc.events.FaultEvent;

 

 

import

mx.utils.ObjectUtil;

 

 

import

mx.controls.Alert;

private

 

 

var openFile:File = new

File()

 

private

 

 

function openBrowseWindow():void

{

openFile.addEventListener(Event.SELECT, onOpenFileComplete);

openFile.addEventListener(Event.OPEN, load);

openFile.browse();

}

 

private

 

 

function load():void

{

Alert.show(

 

"load"

);

 

 

var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png"

);

 

 

//var textTypes:FileFilter = new FileFilter("Text Files (*.txt, *.rtf)", "*.txt; *.rtf");

 

 

var allTypes:Array = new

Array(imageTypes);

openFile.browse(allTypes);

 

}

 

 

private

 

 

function faultHandler(event:FaultEvent):void

{

 

 

//Alert.show("Fault")

Alert.show(ObjectUtil.toString(event.fault));

}

 

 

private

 

 

function pathresult(event:ResultEvent):void

{

Alert.show(

 

"res"

)

 

 

//Alert.show(ObjectUtil.toString(event.result));

}

private

 

 

function onOpenFileComplete(event:Event):void

{

 

 

//mx.controls.Alert.show("event: "+event.target.nativePath +"UR!!!");

 

 

var

pPath = event.target.nativePath;

 

 

var parameters:Object = {FlexActionType:"PATH"

,path:pPath};

 

 

// Alert.show("Image Selected from Path : "+pPath);

urlpath.send(parameters);

 

 

//Alert.show("Passed.."+parameters);

}

 

]]>

 

 

</mx:Script>

 

 

<mx:Button click="openBrowseWindow();onOpenFileComplete(event)" name="Upload" label="Upload" x="120.5" y="10"

/>

 

Here is Mxml Code for Flex Application

 

 

 

 

 

 

 

 

 

 

 

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application

 

 

xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns="http://ns.adobe.com/air/application/1.0.M4"

>

 

 

 

<mx:Script>

<![CDATA[

 

 

import

mx.controls.Alert;

 

 

private function Upload():void

{

 

 

 

// CursorManager.setBusyCursor();

 

 

//var url:String = "HomeAction.do?method=onLoad";

 

 

//var url:String = "assets/Air.swf";

 

 

var url1:URLRequest = new URLRequest("assets/Air.swf"

);

navigateToURL(url1,

 

"_self"

);

 

 

// CursorManager.removeBusyCursor();

}

]]>

 

 

</mx:Script>

 

 

<mx:LinkButton id="up" click="Upload()" x="295" y="215" label="UpLoad"

/>

 

In this code i forward using s url to Open tat  Desktop application but a blank screen appears with out the proper output...

 

 

Please Help me in this to forward AIR from Flex Screen..

 

 

Thanks in Advance

 

With Regards

 

Gopinath.A

Software Developer

First Internet Systems Pvt. Ltd.,

Chennai

 

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points