hide side navigation
    5 most recent
    Web Services
    Library's
    Component's
    Applications
    Articles
  Flash streaming servers  Flash button as Flex icon  Flex form by email  Hello Remoting with AS3  AS3 Saving data from Flash  AS3 Loading data into Flash  Fire Effect  Contact form  Dragable buttons  Hello World with openamf  Loading helper classes  Upload with Flash 8  Transitions effects  Snapshot with Flash 8  Hello World Remoting AS2  Flash AS2 Remoting Connector  Saving data from Flash  Loading data into Flash  FlashCom & Remoting login  Cell Renderer API  Editing a table using remoting components  Flash MX2004 web service classes  Browsing a catalog  amfphp Documentation  Hello World Remoting  Online Store with AMFPHP  Flash clients for Web Services  Web Service Walk Though with NuSoap  Popup windows in flash with javascript  Installing Apache/PHP  MoreOver News Feeds  Load Edit Save Text Files via CGI  Save Movie Clip Postion via PHP and MySQL
Current Page (1) Next Page >>  View Article Example >> 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
Untitled Document

1. General loading principles

Flash can load data as big pieces of string. a list of name/value pairs. What I mean? That data must be a named variable with some value, like this:

name=Jorge

Here I have a variable named "name" with a value "Jorge". But what happens if I need more info, perhaps last name and age? I can use a string like this:

name=Jorge&lastname=Solis&age=30

Now I have three variables, each one holding a different information. Note that I use the "&" sign to separate values. This way I can pass any quantity of data to Flash, each one in a name/value pair format. This info could be in any file as far as it can be loaded by our movie.

Now let's move to the Flash side There are a couple of ways of loading data, basically loadVariables() and the LoadVars() object. Since the better approach is to use the LoadVars object, because encapsulation and callback handlers, we will explain only this way of loading data.
So, having name=Jorge in a text file named data.txt, I can use this:


    myData 
= new LoadVars()
    
myData.load("data.txt")
    
myData.onLoad = function(succes){
      if(
succes){
          
name.text this.name
      
} else trace ("Error loading data")
    }

So here we first instantiate a LoadVars object, then we use the load method to load the content of the text file, and finally we use the onLoad handler that fires when the content is totally loaded, to assign it to a textfield. The succes parameter is a boolean value set to true if the data has successfully loaded, if not, we trace an error message to the output window. This way of loading data has two important features:

- Data is encapsulated, so it doesn't overwrite any other variable in our movie
- We don't need to loop until data finish to download, since the onLoad handler take care of this.

We will follow this way of loading data in all our examples.

Examples

So we have seen how Flash reads name/value pairs and how to use a LoadVars object to load it. Use the examples files from the source in this tutorial to follow next chapters. Each method is inside his own folder (txt, XML, DB and remoting)

Now move to our example using a text file.

 

Current Page (1) Next Page >> 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8