SePP
06-15-2005, 06:23 PM
I use following code to let users draw in my flash movie.
i=0;
this.createEmptyMovieClip("pic", 1);
pic.lineStyle(0.25, 0x999999, 100);
pict = new Array();
myPic = SharedObject.getLocal("foo");
this.onEnterFrame = function(){
_root.potlood._x = _root._xmouse;
_root.potlood._y = _root._ymouse;
}
function XYdefine(){
mx = _xmouse;
my = _ymouse;
if(mx < 100 && mx >= 10 && mx > 0) {
mx = "0"+_xmouse;
} else if(mx < 10 && mx > 0) {
mx = "00"+_xmouse;
}
if(my < 100 && my >= 10 && my > 0) {
my = "0"+_ymouse;
} else if(my < 10 && my > 0) {
my = "00"+_ymouse;
}
}
function save(t) {
XYdefine();
i++;
pict[i] = t + "," + mx + "," + my;
myPic.data.pict = pict;
pict.flush();
// trace(pict); //this just here for checking. obviously.
}
this.onMouseDown = function() {
if(_xmouse > 0 && _xmouse < Stage.width && _ymouse > 0 && _ymouse < Stage.height) {
pic.moveTo(_xmouse, _ymouse);
mousedown = 1;
save(1);
}
}
this.onMouseMove = function() {
if (mousedown && _xmouse > 0 && _xmouse < Stage.width && _ymouse > 0 && _ymouse < Stage.height) {
pic.lineTo(_xmouse, _ymouse);
save(0);
}
}
this.onMouseUp = function() {
mousedown = 0;
}
It saves the drawing the user made to a SharedObject.
My question is, is it also possible to save the drawing to a db trough PHP for example? And is it possible to retrieve and recreate it back in flash trough XML?
I want my users to see the drawings others made in my flash movie. I haven't got comm. server. That's why I try to work around things.
Thanks !!
i=0;
this.createEmptyMovieClip("pic", 1);
pic.lineStyle(0.25, 0x999999, 100);
pict = new Array();
myPic = SharedObject.getLocal("foo");
this.onEnterFrame = function(){
_root.potlood._x = _root._xmouse;
_root.potlood._y = _root._ymouse;
}
function XYdefine(){
mx = _xmouse;
my = _ymouse;
if(mx < 100 && mx >= 10 && mx > 0) {
mx = "0"+_xmouse;
} else if(mx < 10 && mx > 0) {
mx = "00"+_xmouse;
}
if(my < 100 && my >= 10 && my > 0) {
my = "0"+_ymouse;
} else if(my < 10 && my > 0) {
my = "00"+_ymouse;
}
}
function save(t) {
XYdefine();
i++;
pict[i] = t + "," + mx + "," + my;
myPic.data.pict = pict;
pict.flush();
// trace(pict); //this just here for checking. obviously.
}
this.onMouseDown = function() {
if(_xmouse > 0 && _xmouse < Stage.width && _ymouse > 0 && _ymouse < Stage.height) {
pic.moveTo(_xmouse, _ymouse);
mousedown = 1;
save(1);
}
}
this.onMouseMove = function() {
if (mousedown && _xmouse > 0 && _xmouse < Stage.width && _ymouse > 0 && _ymouse < Stage.height) {
pic.lineTo(_xmouse, _ymouse);
save(0);
}
}
this.onMouseUp = function() {
mousedown = 0;
}
It saves the drawing the user made to a SharedObject.
My question is, is it also possible to save the drawing to a db trough PHP for example? And is it possible to retrieve and recreate it back in flash trough XML?
I want my users to see the drawings others made in my flash movie. I haven't got comm. server. That's why I try to work around things.
Thanks !!