07.12.2012 Views

Adobe Director Basics

Adobe Director Basics

Adobe Director Basics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ADOBE DIRECTOR BASICS<br />

Asynchronous programming<br />

Testing a postNetText() with an invalid file path to the remote server<br />

If you click on the PHPQuery() button, you see that the progress bar starts to move, and then an error message appears.<br />

This indicates that the domain name and folder path used in the PHPQuery() handler of the PHP Query movie script<br />

are invalid. You then need to edit the following hard-coded lines, using the values appropriate for your own server:<br />

vFolder = "http://my.example.com/director/"<br />

vPHP = "test.php"<br />

You may want to use a call to a PHP script to return an image. Displaying an image retrieved from a PHP script in a<br />

Shockwave movie requires special care. The importFileInto method will not work. If you set the fileName (Member)<br />

of a Bitmap member to the URI of the PHP script, then the operation may fail. It will only succeed if you set the<br />

fileName of a member that is already linked to an external file.<br />

Use the following steps to ensure that you can display the image:<br />

1 Create a tiny placeholder image file and place it alongside your <strong>Director</strong> movie<br />

2 Import this placeholder image as a Bitmap, using the Link To Exernal File option<br />

3 When your PHP operation completes, set the fileName of this linked Bitmap member to the URI of the PHP script.<br />

Querying a MySQL database<br />

Many projects require a <strong>Director</strong> movie to communicate with an online database. For example, you may be creating a<br />

game with a high-score table, and the scores may be recorded in a database on your web server. One common scenario<br />

is the use of a PHP script that queries a MySQL database on the same server. When the MySQL data returns a response<br />

to the PHP script, the PHP script can echo information back to the <strong>Director</strong> movie.<br />

The following is an extract of a PHP script which makes a query to a MySQL database.<br />

$sql = " SELECT DISTINCT id, screenName, userName FROM User<br />

WHERE User.username = TEST NAME'<br />

AND User.password = 'TESTING'";<br />

$result = mysql_query($sql);<br />

You may want to return the result as an XML string. To do so, use the XML Parser Xtra to convert it to a format that<br />

<strong>Director</strong> can use.<br />

Alternatively, you can prepare the output in a format that <strong>Director</strong> can easily convert to a property list. This has the<br />

advantage of using less bandwidth than the same data formatted is an XML string. The disadvantage is that the PHP<br />

developer will need to use a proprietary format for the output.<br />

Last updated 8/26/2011<br />

441

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!