I am trying to generate random motion in flash and can’t seem to make it work.
Any help will be much appreciated
newpos = function () {
ranx = Math.random ()*250);
rany = Math.random ()*250);
}
this.onEnterFrame = function() {
newpos ()
this._x = ranx;
this._y = rany;
}
acceleration = 10
newpos = function () {
ranx = Math.round((Math.random ()*250));
rany = Math.round ((Math.random ()*250));
}
newpos();
this.onEnterFrame = function() {
this._x += ((ranx-this._x)/ acceleration);
this._y += ((rany-this._y)/ acceleration);
};
acceleration = 10
newpos = function () {
ranx = Math.round((Math.random ()*250));
rany = Math.round ((Math.random ()*250));
}
newpos();
this.onEnterFrame = function() {
this._x += ((ranx-this._x)/acceleration);
this._y += ((rany-this._y)/acceleration);
if (Math.round(this._x) == ranx || Math.round(this._y) == rany) {
newpos();
}
};