View Full Version : [AS2] saving dynamic movie clips to mysql
omerts
04-28-2009, 11:26 PM
dear forum friends,
I have created a flash game which you can duplicate, drag, and rotate, 4 different types of movieclips.
what i need is to add a save button which will save all the current movie clips on stage and their position into a mysql database.
also i need that when the game is opened it will fetch and create all the movie clips in the database.
thanx in advance for all the helpers
ImOnCloudNine69
04-28-2009, 11:41 PM
the only way to do this is to send the names and postions, (x and y, and rotation degrees if you do this) to php via getURL in flash
and GET on the php side
then from there you can use php to put into a database.
omerts
04-29-2009, 07:31 PM
thanx for the reply
since i am a newbie at actionscript, I need some further information.
How can i get a list of all movie clips on stage, name and position? especially when the movie clips are created during the game.
With php i have no problem.
bluemagica
05-02-2009, 08:33 PM
it all depends on how you want to create your movieclips! When you create your movieclips, you can push them in an array, and then send its contents to php! Explain your structure/approach, and i will try to help you!
And read the following link:
http://www.kirupa.com/developer/actionscript/flash_php_mysql.htm
omerts
05-12-2009, 08:16 PM
sorry for the long delay...
this is the code of the movieclips i want to save.
basically there is a user cookie, and i need to save the movieclips name and location to a mysql database, and then retrieve them by the username the next time he opens the movie clip
stop();
var lastClicked:MovieClip;
var numbers3 =numbers+"("+numbers2+")";
numequal.text=numbers3;
var num = 0;
var num2 = 0;
var num3 = 0;
var num4 = 0;
var mcArray:Array = new Array();
var counter:Number = 0;
function drag() {
this.startDrag();
lastClicked=this;
var rocket = this;
moveUp.onPress = function() {
rocket.onEnterFrame = function() {
this._y -= 4;
};
};
moveUp.onRelease = function() {
delete rocket.onEnterFrame;
};
moveDown.onPress = function() {
rocket.onEnterFrame = function() {
this._y += 3;
};
};
moveDown.onRelease = function() {
delete rocket.onEnterFrame;
};
moveRight.onPress = function() {
rocket._x += 4;
};
moveLeft.onPress = function() {
rocket._x -= 4;
};
rotateCW.onPress = function() {
rocket.onEnterFrame = function() {
this._rotation += 3;
};
};
rotateCW.onRelease = function() {
delete rocket.onEnterFrame;
};
rotateCCW.onPress = function() {
rocket.onEnterFrame = function() {
this._rotation -= 3;
};
};
rotateCCW.onRelease = function() {
delete rocket.onEnterFrame;
}
}
my_mc.onPress = function() {
num+=12;
ci_num2.text=num;
ciequal.text=num+num2+num3+num4;
var t = attachMovie("mc", "mc"+counter, this._parent.getNextHighestDepth());
counter++;
t._x = this._x;
t._y = this._y;
mcArray.push(t);
t.startDrag();
lastClicked=t;
t.onMouseUp = function() {
this.stopDrag();
for (i=0; i<mcArray.length; i++) {
if (mcArray[i].hitTest(_root.bin_mc)) {
removeMovieClip(mcArray[i]);
mcArray.splice(i, 1);
}
}
delete t.onMouseUp;
};
t.onPress = drag;
t.onRelease = onReleaseOutside=dragEnd;
};
my_ci.onPress = function() {
num2+=8;
ci_num.text=num2;
ciequal.text=num+num2+num3+num4;
var t = attachMovie("ci", "ci"+counter, this._parent.getNextHighestDepth());
counter++;
t._x = this._x;
t._y = this._y;
mcArray.push(t);
t.startDrag();
lastClicked=t;
t.onMouseUp = function() {
this.stopDrag();
for (i=0; i<mcArray.length; i++) {
if (mcArray[i].hitTest(_root.bin_mc)) {
removeMovieClip(mcArray[i]);
mcArray.splice(i, 1);
}
}
delete t.onMouseUp;
};
t.onPress = drag;
t.onRelease = onReleaseOutside=dragEnd;
};
t2.onPress = function() {
num3+=18;
ci_num3.text=num3;
ciequal.text=num+num2+num3+num4;
var t = attachMovie("square2", "square2"+counter, this._parent.getNextHighestDepth());
counter++;
t._x = this._x;
t._y = this._y;
mcArray.push(t);
t.startDrag();
lastClicked=t;
t.onMouseUp = function() {
this.stopDrag();
for (i=0; i<mcArray.length; i++) {
if (mcArray[i].hitTest(_root.bin_mc)) {
removeMovieClip(mcArray[i]);
mcArray.splice(i, 1);
}
}
delete t.onMouseUp;
};
t.onPress = drag;
t.onRelease = onReleaseOutside=dragEnd;
};
t3.onPress = function() {
num4+=24;
ci_num4.text=num4;
ciequal.text=num+num2+num3+num4;
var t = attachMovie("square3", "square3"+counter, this._parent.getNextHighestDepth());
counter++;
t._x = this._x;
t._y = this._y;
mcArray.push(t);
t.startDrag();
lastClicked=t;
t.onMouseUp = function() {
this.stopDrag();
for (i=0; i<mcArray.length; i++) {
if (mcArray[i].hitTest(_root.bin_mc)) {
removeMovieClip(mcArray[i]);
mcArray.splice(i, 1);
}
}
delete t.onMouseUp;
};
t.onPress = drag;
t.onRelease = onReleaseOutside=dragEnd;
};
reset.onRelease = function(){
loadMovieNum("kaan.swf", 0);
};
function dragEnd() {
if (lastClicked.hitTest(_root.bin_mc)) {
var lastClicked2:String = lastClicked._name;
if(lastClicked2.indexOf("mc")>-1)
{
num-=12;
ci_num2.text=num;
ciequal.text=num+num2+num3+num4;
}
else if(lastClicked2.indexOf("ci")>-1)
{
num2-=8;
ci_num.text=num2;
ciequal.text=num+num2+num3+num4;
}
else if(lastClicked2.indexOf("square2")>-1)
{
num3-=18;
ci_num3.text=num3;
ciequal.text=num+num2+num3+num4;
}
else if(lastClicked2.indexOf("square3")>-1)
{
num4-=24;
ci_num4.text=num4;
ciequal.text=num+num2+num3+num4;
}
}
for (i=0; i<mcArray.length; i++) {
if (mcArray[i].hitTest(_root.bin_mc)) {
var check:String = mcArray[i];
removeMovieClip(mcArray[i]);
mcArray.splice(i, 1);
}
}
this.stopDrag();
}
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.