Flash AS3 Tutorials Center | Interesting Flash Animation Tutorials | Valuing Flash Animation Tutorials | Flash ActionScript and Animation Home

AS3 Beginner Tutorials | AS3 Basic Lessons | AS3 Valuing Courses | AS3 Components Tutorials | AS3 and PHP Interaction Tutorials
AS3 Practical Tutorials | AS3 Animation Techniques | AS3 Transition Effects Tutorials | AS3 Download Upload Files | AS3 Particle Systems
Communication Between Flash Movies with AS3 | AS3 and JavaScript interaction | AS3 Matrix Transformation | AS3 Physics Simulation Tutorials

Flash Text Database Tutorial: Database Structure after Load into Flash Movie

This is the first Flash ActionScript tutorial of basic text database manipulation. Let's examine if there is any changes of the database structure after loading into a Flash Movie.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

The first step is try to use ActionScript to load the external text file (database) into the Flash Movie and examine the structure of the database.

You should notice that an empty line is inserted betwen each record after the database was loaded into the Flash Movie.

The complete Flash Movie is shown as above, you may try how it works before you start this tutorial.

Flash ActionScript Codes:

//You can declare the url of the text file as string
//so that you can use it later
var url:String = "staff.txt";

//Create a URLLOader object with the name myLoader
var myLoader:URLLoader = new URLLoader();

//Load the text file by using URLRequest
//Can be local file or URL of webpage
myLoader.load(new URLRequest(url));

//Listen when the loading of text file COMPLETE
//Call the loadComplete function when the loading COMPLETE
myLoader.addEventListener(Event.COMPLETE, loadComplete);

//Declare some variables to use later
var myString:String;

function loadComplete(evt:Event) {

//Assign the loaded file into a string (myString)
myString = evt.target.data;

//Display the file content
output_txt.text = myString;

//Remove Listener that no longer in use
myLoader.removeEventListener(Event.COMPLETE, loadComplete);

}

 

//////////////////////////////
///// ERROR HANDLING /////
/////////////////////////////

// Listen error events for the loading process
// Call loadError function in case an error appear
myLoader.addEventListener(IOErrorEvent.IO_ERROR, loadError1)
myLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, loadError1)
myLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, loadError2)

 

function loadError1(event:ErrorEvent):void {

// Display error message to user in case of loading error.
output_txt.text = "Sorry that there is an error during the loading of an external text file. The error is:" + "\n" + event.text;
}

 

function loadError2(event:HTTPStatusEvent):void {

// Display error message to user in case of loading error.
output_txt.text = "Sorry that there may be an error during the loading of an external text file. The error is:" + "\n" + event.status;
}

Download Flash Source File:

Flash Source File text-database-1.fla

Remarks:

This Flash ActionScript tutorial examine the database structure after loaded into Flash Movie.