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 AS3 PHP Interaction - PHP Fetch Contents from Website

This Flash ActionScript PHP Interaction tutorial also shows how to load the output of the PHP file into Flash. The PHP file use to fetch contents from a web hosting website.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

This is a very useful Flash ActionScript technique that use PHP to load web contents from websites.

The first Flash Movie of this tutorial is shown as above.

PHP File Codes:

There are many free PHP codes on the Internet that used to fetch contents from website. Here's some of the PHP codes:


// Contents fetch from website
$url = "http://www.mygreatname.com/index.html";

// file to write to the fetched contents
$file = "content.inc";

// Start and End of fetched contents
$unique_start = "Providing";
$unique_end = "Find";

// More codes here

$fd= fread(fopen("$url", "r"), 100000);

// More codes here

// Output the web contents
echo $contents;


The output of the above PHP file is "Providing affordable web hosting and cheap web host since 2000."

Flash ActionScript Codes:

// define the PHP file that will be loaded
var phpFile:String = "fetch_website.php";


function loadFile(evt:MouseEvent):void {

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

// Specify dataFormat propery of the URLLoader to be "TEXT"
// (This step is optional since the default dataFormat is "TEXT"
myLoader.dataFormat = URLLoaderDataFormat.TEXT;

//Load the text file by using URLRequest
var urlRequest:URLRequest = new URLRequest(phpFile);

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


function loadComplete(evt:Event):void {

//Display content in Message Box
output_txt.htmlText = evt.target.data;


// Hook up the button with the function loadFile
enter_btn.addEventListener(MouseEvent.CLICK, loadFile);

Download Flash Source File:

Flash Source File as3-php-communication-02.fla


This Flash ActionScript PHP tutorial shows how to load web contents from websites.