|
This tutorial is a basic tutorial for Flash devlopers who want to create a user-interactive movie and allow users to store the data using php or the shared object. In the following I will mainly focus on the php version, which is a AS2 class file. The downloadable files, however, also contain a file where the shared object is applied. Now let's start. First test the movie to see its functionality. The Flash AS fileIn the following we will look at the script. I prefer AS2 class scripts, because they have to be "clean" with all the correct datatypes. The movie is set up as one movieclip with a linkage id. As AS2 class we enter Memory, which is the name of the class file. We place one instance of this movieclip on stage and give it a name like mcGame. Then we 2 functions on the main timeline for saving and the stored data and setting the stage from the stored data. Also we place the commands to move the squares aroud here.// FLA FILE SCRIPT // // Functions to set the stage and store data // mcGame.setStage (); mcGame.storeData (); // // drag functions for the movieclips. // mcGame.square1.onPress = function () { this.startDrag (); }; mcGame.square1.onRelease = function () { this.stopDrag (); }; mcGame.square2.onPress = function () { this.startDrag (); }; mcGame.square2.onRelease = function () { this.stopDrag (); }; mcGame.square3.onPress = function () { this.startDrag (); }; mcGame.square3.onRelease = function () { this.stopDrag (); }; mcGame.square4.onPress = function () { this.startDrag (); }; mcGame.square4.onRelease = function () { this.stopDrag (); }; The XML fileNow it is time to have a closer look at the AS2 file. What do we want to achieve?
<?xml version="1.0"?> <game> <square1 x_value="-143" y_value="53">square1</square1> <square2 x_value="137.95" y_value="-97">square2</square2> <square3 x_value="-42" y_value="24">square3</square3> <square4 x_value="-19.05" y_value="-134">square4</square4> </game>On the next page we will discuss the AS2 script Memory.as. |