Ciao ragazzi,
partendo da questo codice che devo inserirlo ogni volta su un mc, volevo creare una funzione.
onClipEvent (load) {
newX = Math.round(Math.random()*200);
accelFactor = Math.ceil(Math.random()*4)+2;
}
onClipEvent (enterFrame) {
currentlocx = this._x;
differencex = newX-currentlocx;
accelx = differencex/accelFactor;
this._x = this._x+accelx;
if (Math.round(this._x) == Math.round(newX)) {
newX = Math.round(Math.random()*200);
accelFactor = Math.ceil(Math.random()*4)+2;
}
}
Io ho provato cosi' ma l'oggetto parte e non si vede più.
function reset(theClip) {
theClip.newX = theClip.Math.round(theClip.Math.random()*200);
theClip.accelFactor = theClip.Math.ceil(theClip.Math.random()*6)+2;
}
function fade(theClip) {
theClip.currentlocx = theClip._x;
theClip.differencex = theClip.newX-theClip.currentlocx;
theClip.accelx = theClip.differencex/theClip.accelFactor;
theClip._x = theClip._x+theClip.accelx;
if (theClip.Math.round(theClip._x) == theClip.Math.round(theClip.newX)) {
theClip.newX = theClip.Math.round(theClip.Math.random()*200);
theClip.accelFactor = theClip.Math.ceil(theClip.Math.random()*6)+2;
}
}
Sul mc ho messo:
onClipEvent (load) {
_root.reset(this);
}
onClipEvent (enterFrame) {
_root.fade(this);
}
![]()