-
Movieclip position in 100 steps
Hi,
i'm trying to make a trace of simple "dot", which is based on my X, Y data. I have one hounderd of X,Y data. I don't know how to make "for" rule to display each X,Y f.e. in 1 second delay / or maybe it will be easier to make next button, which will load another couple of data X,Y.
I made some simply code:
Code:
this.createEmptyMovieClip("this_mc", 1);
this_mc.loadVariables("data.php", "POST");
this_mc.onEnterFrame = function()
{
table = this.table.split(',');
myclip._x = int(table[0]);
myclip._y = int(table[1]);
}
It's working, for first couple of data X,Y. How to make a script for display another 99 couple of data (there could be some "next / prev button").
-
.
Hi,
What is the data coming from your php file?
If it's anything like this txt file,
Code:
12,34,34,45,66,55,5,5,5,667,76,76,4,35,3,5,35,3,533,2,2,2,2,1,1,1,123,123,23,234,234,234
then you can perhaps make something of this
PHP Code:
//this.createEmptyMovieClip("this_mc",1);
var a:Number = 0;
var b:Number = 1;
var xyData:LoadVars = new LoadVars();
xyData.load("data.txt");
xyData.onData = function(Data)
{
if (Data)
{
table = Data.split(',');
//trace(table);
holdSecond = setInterval(doHold, 1000);
}
};
function doHold()
{
myclip._x = table[a];
myclip._y = table[b];
trace(myclip._x + " - " + myclip._y);
if (a >= table.length)
{
clearInterval(holdSecond);
trace("Finished");
}
else
{
a += 2;
b += 2;
}
}
-
Geat!! Thank You fruitbeard.
It works perfect!
-
I would like to make several movieclips. I duplicated movieclip, and duplicated all script You wrote.
Code:
//this.createEmptyMovieClip("this_mc",1);
var a:Number = 0;
var b:Number = 1;
var c:Number = 0;
var d:Number = 1;
var xyData:LoadVars = new LoadVars();
xyData.load("data.txt");
xyData.onData = function(Data)
{
if (Data)
{
table = Data.split(',');
//trace(table);
holdSecond = setInterval(doHold, 50);
}
};
function doHold()
{
myclip._x = ((-1*table[a])/5)+805;
myclip._y = ((-1*table[b])/5)+570;
//trace(myclip._x + " - " + myclip._y);
if (a >= table.length)
{
clearInterval(holdSecond);
//trace("Finished");
}
else
{
a += 2;
b += 2;
}
}
var xyData2:LoadVars = new LoadVars();
xyData2.load("data2.txt");
xyData2.onData = function(Data2)
{
if (Data2)
{
table2 = Data2.split(',');
//trace(table);
holdSecond2 = setInterval(doHold2, 50);
}
};
function doHold2()
{
myclip2._x = ((-1*table2[c])/5)+805;
myclip2._y = ((-1*table2[d])/5)+570;
//trace(myclip._x + " - " + myclip._y);
if (c >= table2.length)
{
clearInterval(holdSecond2);
//trace("Finished");
}
else
{
c += 2;
d += 2;
}
}
Is there a better way to "duplicate code" for for example 20 movieclips?
-
.
Hi,
Perhaps this, although you probably want your data structured differently
the code goes something like this
PHP Code:
var a:Number = 0;
var b:Number = 1;
var i:Number;
var moveTotal:Number;
var dataArray:Array = new Array();
var xyData:LoadVars = new LoadVars();
xyData.load("data.txt");
xyData.onData = function(Data)
{
if (Data)
{
xyList = Data.split("%%");
xyTotal = xyList.length;
for (i = 0; i < xyTotal; i++)
{
dataArray[i] = [];
dataArray[i] = xyList[i].split(",");
}
moveTotal = dataArray[0].length;
holdSecond = setInterval(doHold, 1000);
}
};
function doHold()
{
for (i = 0; i < xyTotal; i++)
{
_root["myclip" + i]._x = dataArray[i][a];
_root["myclip" + i]._y = dataArray[i][b];
trace(i + " : " + _root["myclip" + i]._x + " - " + _root["myclip" + i]._y);
}
if (a >= moveTotal)
{
clearInterval(holdSecond);
trace("Finished");
}
else
{
a += 2;
b += 2;
}
}
and the data.txt like so
Code:
12,34,34,45,66,55,5,5,5,667,76,76,4,35,3,5,35,3,533,2,2,2,2,1,1,1,123,123,23,234,234,234%%120,74,84,45,96,85,45,45,45,67,36,26,33,34,35,55,45,3,33,28,26,24,23,12,31,1,13,23,23,134,14,104%%20,24,24,25,26,45,65,65,65,27,36,56,53,54,55,65,75,89,37,28,277,240,230,102,301,10,103,203,203,134,104,14
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|