A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11337 Flash Movies | 1 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Bugra Ozden
» Title: Skatalog v9 - product catalog
» Description: Create your product catalog easly and publish on your website or Create your image gallery, documents list, portfolio. Fully XML Driven
» More by Bugra Ozden


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5828 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: Creative DW Image Show PRO
» Description: Creative DW Image Show PRO is a Dreamweaver extension which enables the user to create multimedia presentations. It combines the features of the popular Creative DW Image Show with the ability to add professional text effects to slides (similar to After Effects). The product is very customizable: the user can choose the duration of the transition effects, the slide motion start and end position, zoom and panning type for both images and texts.


Random Links | Add your own Flash Related Links
Flash Tutorials 1280 Tutorials 7 New Tutorials Added!
What's New | Top100

» Make a Flash Slide Show Screen Saver
» Simple flash making tutorial for thanksgiving
» Create flash banner for website
» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» Unknown Tag: Title10
Random Tutorial | Add Site

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Backend

Categories mySQL and PHP - Login and Registration - Saving Movie Clip ('s) Position
Author: Jeffrey F. Hill | Website: http://www.snowvids.com |

 
Page 6
«prev 1 2 3 4 5 6 7 next»

Loading the Variables

PHP used the Loading Variables Part (Load.php)

The load variables part is not important the first time a user enters the room.  It does become important when a user moves the objects then returns to the room at a later time.  This is what loads them all into the same place as when the user left.  It also Loads a comment that the user can optionally leave. Here's what the basic script looks like.  Again it is strongly recommended to follow along by also reading the php script. They are commented in much more detail. 

$result = mysql_query("SELECT * FROM $table WHERE Name = '$Name'");
 ##This sets the variables from the Database
 $Comment = mysql_result($result,0,"Comment");
 $Object1 = mysql_result($result,0,"Object1");
 $Object2 = mysql_result($result,0,"Object2");
 $Object3 = mysql_result($result,0,"Object3");
 if ($Comment == "") {
$Comment = "Hello $Name";
}
#This next bit prints out the value's of the Comment and the positions
#of the three objects whose properties you want to save. This is the line that Flash will read into the movie. 
print "Comment=$Comment&$Object1$Object2$Object3";

The first line of code just selects the record in the database where the Name that the person Logged in as matches the Name in the Database. After this each column in the result record set is set to a variable.  This basically just extracts the result you got from the query and puts it into variables that you can use.  The if statement is necessary to make sure that the Comment variable contains some value. This will be explained later.  The last line of Code prints the results back to Flash.  Notice how Object1, Object2, and Object3 are not separated by the & symbol. This is because the & symbols already exist in the database - when you update the database these are included. Not necessary but just makes it easier.

Actionscript used to Load the Variables into the Movie

In the 4th frame of the movie the following actionscript is attached to a frame:

// Loads the Variables
loadVariablesNum ("Load.php?Name="+Name, 0);
gotoAndPlay (6);

What this does is to Load the variables from the database and stick them into the movie.  The variables that get loaded are the x and y coordinates for each of the 3 objects in the movie.  After it makes the call to the script it goes onto Play Frame 6 of the Movie.  We let the script play for a couple frames then check to see if the variables have been loaded. If they have been loaded we continue on in the movie. If not we continue to wait until they are.  We do not need to check if they've all been loaded so we just check to see if the variable Comment has been loaded from the Database.  Here's the script for the second check. Which brings us to the final stage of the tutorial. 

if (Comment ne "") {
setProperty ("Object1", _x, xO1);
setProperty ("Object1", _y, yO1);
setProperty ("Object2", _x, xO2);
setProperty ("Object2", _y, yO2);
setProperty ("Object3", _x, xO3);
setProperty ("Object3", _y, yO3);
gotoAndPlay (19);
}
else {
gotoAndPlay (6);
}

Notice how that unless Comment has a value it will loop back to Frame Number 6.  If Comment is equal to a value then it will set the x and y positions of the Movie Clips then continue and Play Frame number 19. 

Updating the Variables in the Database

The last part of this tutorial involves Updating the variables x and y position in the Database as well as the user entered Comment. First we need to use actionscript to get the x and y positions of the Movie Clips as they are moved around by the User.

O1x = math.floor(getProperty(_root.Object1, _x));
O1y = math.floor(getProperty(_root.Object1, _y));
O2x = math.floor(getProperty(_root.Object2, _x));
O2y = math.floor(getProperty(_root.Object2, _y));
O3x = math.floor(getProperty(_root.Object3, _x));
O3y = math.floor(getProperty(_root.Object3, _y));

This is done simply by using the getProperty function to return the x and y position of each movie clip.  I also use the math.floor function so that the x and y positions are rounded to the nearest integer.  This is not necessary buy why have all those extra numbers in your database when no one will ever no the difference. This is repeated twice.  Then on the last frame it continues to loop back to the first instance of this code so that they postitions are continually updated.

The PHP used in Updating the x and y positions along with the Comment (Update.php)

$query = "UPDATE saveMovie SET Object1='xO1=$O1x&yO1=$O1y&',  Object2='xO2=$O2x&yO2=$O2y&',
Object3='xO3=$O3x&yO3=$O3y' , Comment='$Comment'  WHERE Name='$Name'";
$result = mysql_query($query);
print "_root.UpdateStatus=Success Updated - It's saved $Name";

This part of the script updates and set's the variables from the movie to the database.  Basically this takes the values that you obtained with the getProperty function and sticks them in the database.  The print statement just lets you know that everything went successfully.

The Actionscript used for updating the variables

on (release) {
 loadVariablesNum ("Update.php?Name="+Name+"&Comment="+Comment+"&O1x="+O1x+"
 &O1y="+O1y+"&O2x="+O2x+"&O2y="+O2y+"&O3x="+O3x+"&O3y="+O3y, "0");
 _root.UpdateStatus = "Updating..";
}

This part is probably easier accomplished by just using the "Post" option of the loadVariablesNum function -which will load all the variables in the movie to the script. But I just attached them all onto the end of the url to the php script.  Mostly because it's easier to test and you know exactly what is being passed. 

«prev 1 2 3 4 5 6 7 next»

» Level Advanced

Added: : 2001-07-03
Rating: 8.15 Votes: 115
Hits: 5780
» Author
No details available.
» Download
Download the files used in this tutorial.
Download (74 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs