Integration of Flash with Web Service of C#

In this article I’m going to show how to consume a Web service and some of the pros and cons of it. When you’re done reading you should have an understanding of what data binding is, how to use it in your applications, and how to achieve similar results without using it.

Unfortunately for some, Flash Professional is required to follow along with the examples. If you haven’t upgraded Flash to the Professional version yet, taking advantage of the Web service integration and data binding might just be a good enough reason to.

What Are Web Services?
A Web service is, more or less, a remote procedure call wrapped in an XML package and typically transmitted over HTTP. You make a request to the URL of the Web service, passing in any appropriate parameters, and are greeted with an XML packet containing the result of the function call. The standard XML format for Web service messages is SOAP – Simple Object Access Protocol.

Web services can be inspected by requesting the WSDL – Web Services Description Language – of the service. The WSDL explains how to interact with the service, what methods are available, what their parameters are, etc. The WSDL format isn’t the easiest to read. Thankfully, Flash will help us out with WSDL interpretation, which we’ll see a little later.

What Is Data Binding?
Now that we have an idea what Web services are, data binding is next on the explanation hit-list. Data binding is… well, magic. Through data binding you can “glue” two separate pieces of a program together. Whenever one piece changes the other piece will automatically notice that change and update itself without any coding necessary. As an added bonus, data binding can be a one- or two-way street.

Data binding is remarkably simple to use and can be done without writing a single line of code. Because of this, it’s a blessing and a curse at the same time. It eliminates the need for you to program what could be complex interactions, but the “magical” aspects of data binding can make it a maintenance nightmare.

In the coming examples, I’ll show you how to use it, how to avoid using it, and finally make some recommendations for when data binding is appropriate.

How to bind a Web Service with Flash?

1- First make a simple web service that fetch data from data base like Sql Server 2005 and return data in objects like:-

pro[i] = new ProDetail();
pro[i].Pro_name = row[0].ToString();
pro[i].Pro_type = row[1].ToString();
pro[i].Pro_color = row[2].ToString();
pro[i].Price = row[3].ToString();
pro[i].Description = row[4].ToString();


2- Then open Flash Professional 8, and goto Window and select Components
3- then click on User interface and drop Text Area onto the stage.


4- Give Instance Name to the Text Area in Properties panel.
Now go to Window and click on Other Panels and select Web Services


6- Now click on Glob and give the WSDL address of web service which would be like this.




7- After giving WSDL address of web service to Glob, Flash will have all the methods, your web service have.


8- the method you want to use just Right click on it and select Add Method Call (An instance of the Web Service Connector component would be added to the stage) as shown in fig:-




9- Name the Web Service Connector component from the “Properties” panel.

Bind Web Service Result to the UI Component:

10- In order to display the results returned from the web service, you need to bind the result to the Text Area component you placed on the stage. Go to Window > Development Panels > Component Inspector. Select the Text Area component on the stage and go to the “Bindings” tab on the “Component Inspector” window. Click the “+” Add Binding button. Select “text : String” from the list and click the OK button.

11- Now click on Bound To in the Component Inspector, a window will open. Click on Web service Connector and at left side (Schema Location) select the object you want to bind with Text Area component and click OK.

12- And set Direction “In”.

13- Now bind the Web Service connector and set its Direction “out” and click on Bound To bind with Text Area in the Component Path.


14- Now create another layer and name it “Action’.

15- Now type the following action:-


16- Now play your movie and see that what ever in your database, flash displays…



2 thoughts on “Integration of Flash with Web Service of C#

  1. The images don’t appear now. Also, I am using FlashLite 3.0 (AS 2.0).

    The SoAP method is:



    I don’t understand how to pass data in this complex format.

    My code is:

    import mx.remoting.*;
    import mx.rpc.*;

    var registerUser:Object;

    var myWebServiceObject = new WebService(“”);

    myWebServiceObject.onLoad = function()
    trace(“Success call for WSDL”);

    myWebServiceObject.onFault = function()

    var MyPendingCallObject:PendingCall = myWebServiceObject.registerUser();

    MyPendingCallObject.onResult = function(result)
    trace(“Result = ” + result);

    MyPendingCallObject.onFault = function(fault)
    trace(“Fault = ” + fault.faultstring);

  2. I have used the WSDL with SoAP calls. The data transfer works fine with Publish Settings as FlashPlayer 8 (AS2.0) but not with FlashLite 3.0. What is the problem?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s