As a person whose experience in programming is connected mainly to Director and Lingo, I often searched but never found a comparatively simple and clear tutorial that describes step by step what is necessary to do in order to get an application, which communicates in a duplex way to a MySQL database. Here I will try to explain how to achieve this on your local machine, under Windows — if the reader has already read such tutorials he or she may skip the following lines.
Generally, to get this you need: a web server, a MySQL server, a database, a Director application, as well as something for the communication between the application and the MySQL server. In our case this will be PHP.
For our convenience and quickness, in this tutorial we will use XAMPP and thus we will get in one fling a web server ( working with PHP4 and PHP5 ) and MySQL server.
1. Download and install XAMPP. Leave all the settings by default. After the installation process is finished a directory “c:\xampp\” must have been created.
2. In the directory “C:\xampp\htdocs\” create another directory called “DirectorTest\”. After that download this fileDirector Test Database (9770 downloads)
and save it in the directory.
3. Choose Start > Programs > XAMPP For Windows > XAMPP Control Panel and start Apache and MySQL. Now you have a working web server, PHP and a MySQL server on your local machine. Test them by opening the browser and try on this address: “http://localhost”. You should see the initial screen of “XAMPP for Windows” — choose a language.
4. Choose PHPMyAdmin, write “directortest” in Create new database text field and click Create.
5. Click Import tab, after that click Choose File button and select “DirectorTestDatabase.sql” file, downloaded and saved in step 2
( The full path to it should be “c:\xampp\htdocs\DirectorTest\DirectorTestDatabase.sql” ) Click GO button. You should see a notice that says “Import has been successfully finished, 16 queries executed.” Now you have a database. There is a table in this database, called “addressbook”, which contains the following columns: id, first_name, last_name, e_mail, phone_number
6. Now here comes the Director application. To spare time, there is an already finished one — download it and save it in “c:\xampp\htdocs\DirectorTest\”Address Book (2588 downloads)
7. Start AddressBook.dir in Director. You will probably see an alert:
"Warning: require_once(DiDal/DiDalHttpHandler.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in C:\xampp\htdocs\DirectorTest\didal.php on line 2 Fatal error:"
8. Now we will introduce DIDAL — Director Data Access Layer — to the whole picture. With Director still opened, download and unzip it in the already familiar directory “c:\xampp\htdocs\DirectorTest\”.DiDAL (7612 downloads)
After unzipping, the directory should look as follows:
DiDal\ AddressBook.dir didal.php didaltest.php DirectorTestDatabase.sql
Start the “AddressBook” application again — now it should look like this:
The following is the recommended way to work with DIDAL:
1. We carefully consider the interactions between the application and the MySQL server and on this basis we define “commands” with parameters. In this particular case the interactions of the application with the server can be reduced to: extracting all the records from the table, called “addressbook”, adding new records to “addressbook” table and deleting records from “addressbook” table. In this case, our command names are sufficiently descriptive — “getAllContacts”, “createNewContact” and “deleteContactById”.
2. We specify the data (parameters) needed for a command to be executed. For example, the execution of “getAllContacts” command does not need any additional data supplied by the application. Obviously, “createNewContact” needs data to be recorded in “addressbook” table. The execution of “deleteContactById” is impossible without supplying “id” of the record which must be deleted.
3. After specifying all this, we open “didal-config.xml” file, which should be in “c:\xampp\htdocs\DirectorTest\DiDal\didal-config.xml”. Pay attention to this line:
<connection host="localhost" username="root" passwd="" dbname="directortest" encoding="cp1251" />
This assigns parameters to the connection with the database.
<command name="yourCommandName" table="databaseTableName"> <![CDATA[ YOUR SQL QUERY; ]]> </command>
So, we see that in this file the two commands — getAllContacts and createNewContact are defined. deleteContactById is not defined. That is why when the execution is started the following alert is generated:
"Fatal error: Call to a member function getTable() on a non-object in C:\xampp\htdocs\DirectorTest\DiDal\DiDalRequest.php on line 55"
Here we define deleteContactById command:
<command name="deleteContactById" table="addressbook"> <![CDATA[ DELETE FROM addressbook WHERE id = :rowid ]]> </command>
Notice that parameters are written with “:” at the begining. We define the command as
IO.registerCommand( "deleteContactById", [ #rowid ] )
in the application. But in the configuration file #rowid parameter is written as :rowid
Have in mind that “table” attribute in
<command name="deleteContactById" table="addressbook">
line will be converted to a symbol when the result of the command is returned. It is necessary this attribute to be present, but it is not necessary for it to correspond to the name of the table, which we reffer in the SQL request.
At the end we must create a projector in order to have a working desktop application. For this purpose you have to create directory c:\xampp\htdocs\DirectorTest\Xtras\
Copy the following files in it:
Proj.dll msvcrt.dll Iml32.dll Dirapi.dll
which can be found in the installation directory of Director ( for example “C:\Program Files\Macromedia\Director MX 2004\” )
Copy “NetLingo.x32”, “INetURL.x32”, “NetFile.x32” files in Xtras directory.
“INetURL.x32” and “NetFile.x32” are in “Your root Director Folder\Configuration\Xtras\Core\Net Support\”
“NetLingo.x32” can be found in “Your root Director Folder\Configuration\Xtras\Scripting\”
In Director, choose from the main menu File > Publish…
In “Select Output directory for AddressBook.exe” dialogue box select “C:\xampp\htdocs\DirectorTest\” directory and click Select Folder.
Here is a working demo: