Advertisement

Using Web Services Creating Live Currency Convertor Mobile App

Author explains step-by-step instruction, how to create your own mobile app using flash builder Burrito.

We know that different countries have different currency and while making the online shopping or any payment option it need to customized to the customer need. Additionally we have the value of the currencies are changing time and time and for objective to give an accurate conversion we need our application to be updated. Usually we get into many of situation in online browsing that the price of the product will be given in dollars and we start to struggle with conversions with approximation of about 50 as multiplication.

Let us create a mobile application to solve this, in order to provide accurate conversion instead of approximately multiplying it with factor we can get rely on web service to do that. Implementing such in the flash builder will be much easier. Now let’s rush to create it in the flash builder Burrito Edition.

Finding Flash Builder Burrito on net
The Adobe Flash Builder Preview edition was freely available at the adobe website. You can find it at http://labs.adobe.com/technologies/flashbuilder_burrito/ and you need to have the Adobe ID to download which you have it by free registration.

Creating New Project:

First launch the Flash Buidler Burrito and you will defaultly naviigated to the Start Page

Then create a new mobile project by menu navigation of File -> New -> Flex Mobile Project

 

Then a window will appear asking the basic detail about the project. Give the project name as you like and Flex SDK version as default that it will take Flex Hero for the development.

 

Next window will ask for the mobile settings and parameters for the mobile configurations. Select the target platform as "Google Android", Application Template as "Mobile Application" and Application Settings as "Automatically reorient" and "Full screen" ticked.

Now move on to next step server settings, we don't need to configure anything now so just skip it without making changes to the defaults there

The next step will be build paths, it ask the location of the libraries, Main source folder, Main application file and Application ID. All the values are defaults no need to chance just click Finish to complete.

You will have project opening view look like this

Now goto the design mode

Now click on action bar at the top with text “Home” and write down the application title.

Then insert a two label box with labels “Dollar” and “Rupee” then create two text boxes near to them with id for them as “us” and “rs”. Place the “us” near to dollar label and “rs” to Rupee label and finally insert a button below with text “Convert”. Id of the element can be changed properties tab.


Or you can simply create this view through this code
      <s:Label x="30" y="177" fontSize="31" text="Dollars:"/>


<s:Label x="78" y="286" fontSize="31" text="Rupees:"/>
<s:TextInput id="us" x="143" y="163" width="222" height="44"/>
<s:TextInput id="rs" x="206" y="280" width="222" height="44"/>
<s:Button x="232" y="467" width="220" label="Convert"/>

So your final view might look like this

Now let’s create the service. You can find it at the bottom, that tab “Data/Services” have the link “Connect to Data/Services…” click to create link

It will ask for the type of service select the type as WSDL “Web Service”

On next screen it will ask for the WSDL URL,  provide the name http://www.webservicex.net/CurrencyConvertor.asmx?WSDL then the remaining fields will be automatically filled.

Then it will ask for the service and the port. Select the port as “CurrencyConvertorSoap” and select the Conversion Rate operation and click Finish to complete.

Then it will create the service

Now the service is ready to connect with. Now right click on the Convert button and select “Generate Service Call”.

Just click Ok to proceed to the coding, now you will be in middle of a code


ConversionRateResult.token = currencyConvertor.ConversionRate(/*Enter value(s) for */ FromCurrency, ToCurrency);

In this change the values to look like this and add two lines of code for obtaining results


ConversionRateResult.token = currencyConvertor.ConversionRate(“USD”,”INR”);
var s:Number;
s=Number(us.text);
s= s * Number(ConversionRateResult2.lastResult);
rs.text =s.toString(10);

Now the conversion rate value is obtained through the web service and it will multiplied to show the INR value. Now run the project as Ctrl + F11. You will get window asking for the run configuration. Give target platform and the launch method as “On desktop “ and now you have chance to select the mobile in which you plan to stimulate, select the device to planned to use the application.

Now click “Run” to start the application. Now enter the value in dollars and click Convert to view the result.

Even you can simulate in the smart phone if you have it, just you need connect it before you run the application. Thus you can see the real run time behavior of the application that you designed. Now you own mobile app ready and it can readily run in the Google android OS, find the app store submit your application enjoy earning money through the mobile application.

About Author:

Parthiban.T is currently doing his BE in Mechanical Engineering at MEPCO SCHLENK ENGINEERING COLLEGE, Sivakasi. You can reach him through deepan2k5@gmail.com

 








Added on May 4, 2012 Comment

Comments

Post a comment