Draw a circle on the stage to convert to a movie clip symbol, the instance name is MC, and the following code is added in the first frame:
function Fanhui (x1, x2, y1, y2) {//compute and return the square root of the defined coordinates and object coordinates added
Sqrt = Math.sqrt (x1+x2+y1+y2);
return Sqrt;
}
function Chushizhi (obja) {
EndX = random (550);//x coordinates defined
EndY = random (400);//x coordinates defined
D = Fanhui (EndX, EndY, obja._x, obja._y);//Get the square root after return
DX = (endx-obja._x)/d*t;//defines the x-coordinate to which an object is to be moved
DY = (endy-obja._y)/d*t;//defines the y-coordinate to which an object is to be moved
}
function tt () {//define the speed of movement
t = random (10);
}
function Yidong (OBJB) {//object move
objb._x = OBJB._X+DX;
objb._y = Objb._y+dy;
}
function Movie (obj) {
if (EndX = = undefined) {//if the defined x coordinate is null execution
TT ();//Running Speed function
Chushizhi (obj);//run definition coordinate function
else if (obj._x>0 && obj._y>0 && obj._x<550 && obj._y<400) {//If the object's coordinates are in the 500* 400 size of the stage in the execution
Yidong (obj);//Run object move function
else {///object coordinates beyond the stage redefine a coordinate in the stage and move to that place
TT ();
Chushizhi (obj);
Trace (ENDX);
Yidong (obj);
}
}
Onenterframe = function () {
Movie (MC);
};
This example mainly demonstrates the transfer application of the parameter, because I didn't understand the parameters at all (although I don't know much now), but for myself there is a new understanding and simple application, to dedicate this to me and the same novice, remember to look at the function in parentheses several times, you will find that they have a certain regularity. I am a child, wish everybody good evening!