2

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?

2
  • Do you mean call a JavaScript method via External Interface? Commented 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. Commented May 14, 2013 at 1:29

1 Answer 1

1

In Flash Builder, under the Data menu, there are data service wizards:

data-services

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

wsdl

Or HTTP Services:

http-service

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:

Sign up to request clarification or add additional context in comments.

2 Comments

Can you also please let me know how can I call this http/SOAP service on double click event?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.