I've just now started working on Flex. May be its basic question but I’m not aware of it – how can I call a java method from actionscript. I want to call some java method on double click of a event. Can you please let me know how to proceed on this?
-
Do you mean call a JavaScript method via External Interface?Jason Sturges– Jason Sturges2013-05-14 01:05:19 +00:00Commented May 14, 2013 at 1:05
-
Thanks for your reply. no, I want to call a java class. basically that java method will call some other we service.Sam– Sam2013-05-14 01:29:32 +00:00Commented May 14, 2013 at 1:29
Add a comment
|
1 Answer
In Flash Builder, under the Data menu, there are data service wizards:

These wizards auto-generate code and are convenient for connecting to WSDL:

Or HTTP Services:

Accessing data services overview has example implementations, such as this example calling a restaurant web service with responder returning value objects from service.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
xmlns:employeesservice="services.employeesservice.*"
xmlns:valueObjects="valueObjects.*">
<fx:Declarations>
<s:WebService id="RestaurantSvc"
wsdl="http://examples.adobe.com/flex3app/restaurant_ws/RestaurantWS.xml?wsdl" />
<s:CallResponder id="getRestaurantsResult"
result="restaurants = getRestaurantsResult.lastResult as Restaurant" />
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
protected function b1_clickHandler(event:MouseEvent):void
{
getRestaurantsResult.token = RestaurantWS.getRestaurants();
}
]]>
</fx:Script>
<s:Button id="b1"
label="GetRestaurants"
click="button_clickHandler(event)" />
</s:Application>
References:
2 Comments
Sam
Can you also please let me know how can I call this http/SOAP service on double click event?
Jason Sturges
Example, and some references added. There are numerous approaches to this both using these wizards as well as programmatic approaches. Data services is a wide topic, but hopefully this demonstrates some options for you to choose in your implementation.