Click here to Skip to main content
13,291,078 members (65,856 online)
Click here to Skip to main content
Add your own
alternative version


43 bookmarked
Posted 4 Jan 2006

Flash and Web Services

, 4 Jan 2006
Rate this:
Please Sign up or sign in to vote.
An easy way to working with Flash and Web Services.


This sample will log you in with a Web Service, serialize the data from a database, and use the serialization class in Flash.


You can get data from a server application in several ways, but I discovered that when working with .NET, using a serialization class is very easy.

Using the code

We will use the a Web Service and a serilazation class and a function in Flash to get the user information. Here is the login method in the Web Service:

public oUsers loginUser(string sUsername, string sPassword)
    oUsers objUsers = new oUsers();
        if( sUsername.Equals("admin") && 
            sPassword.Equals("admin") )
            objUsers.sEmail = "";
            objUsers.sName = "Adam";
            objUsers.sPassword = "admin";
            objUsers.sUsername = "admin";
            throw new ApplicationException("Wrong user!");
        throw new ApplicationException("Error");
    return objUsers;

Here is the serialization class:

public class oUsers
    public string sName;
    public string sEmail;
    public string sUsername;
    public string sPassword;

    public oUsers()

Here is the Flash script for the root:

//stop the secvens of the time line

//importing the webservice classes

//declareing the an global variable for easy access
_global.webServicen = 
  new WebService("http://localhost/WebServiceAndFlash/login.asmx?WSDL");

//cleaning up the textboxes

mcLogin.txtUsername.text = "admin";
mcLogin.txtPassword.text = "admin";
mcLogin.txtName.text = "";
mcLogin.txtEmail.text = "";
mcLogin.txtUser.text = "";
mcLogin.txtPass.text = "";

Given below is the script for the OnClick function:

    var objServicen = _global.webServicen.loginUser(
        _root.mcLogin.txtUsername, _root.mcLogin.txtPassword);
    objServicen.onResult = function(result)
        //declare the Userobject

        var oUser = new objServicen.oUsers();
        oUser = result;
        _root.mcLogin.txtName = "SDF" + oUser.sName;
        _root.mcLogin.txtEmail = oUser.sEmail;
        _root.mcLogin.txtUser = oUser.sUsername;
        _root.mcLogin.txtPass = oUser.sPassword;
    objServicen.onFault = function(fault)
        _root.mcAlert._x = "-0.3";
        _root.mcAlert._y = "-0.7";


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Architect Värderingsdata
Sweden Sweden
Systemdeveloper at Värderingsdata in Sweden

You may also be interested in...


Comments and Discussions

General2010 and yoour code helped me Pin
ZED023-Jun-10 4:19
memberZED023-Jun-10 4:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 4 Jan 2006
Article Copyright 2006 by daniel_nilsson
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid