Hi
How can i make an element fall and when it hits another element called the ground, the falling element goes back up to the top at a random x location?
Thanks
Mousie
Printable View
Hi
How can i make an element fall and when it hits another element called the ground, the falling element goes back up to the top at a random x location?
Thanks
Mousie
code:
onClipEvent(enterFrame){
this._y += 3;
if(this.hitTest(_root.ground)){
reset(); }
function reset(){
this._y = 0;
this._x = random(); }}
I could not get that to work i tried:
var rain = element("rain")
onClipEvent(enterFrame){
>>>>>>>>rain._y += 3;
>>>>>>>>if(rain.hitTest(_root.ground)){
>>>>>>>>>>>>>>>>reset(); }
>>>>>>>>function reset(){
>>>>>>>>>>>>>>>>rain._y = 0;
>>>>>>>>>>>>>>>>rain._x = random(640); }}
i used the >'s to show indentation
Hi,
first create a movie clip of the symbol you want to move down the stage. next select this clip and press F9 to open the actions panel and then enter the following,
code:
onClipEvent(load) {
function reset() {
this._x = Math.round(Math.random() * 500); // set a random x position between 0 and 500 (where 500 is the width of your movie)
this._y = -5; // reset to be just off the top of the stage
this.speed = Math.ceil(Math.random() * 5) + 1; // a random speed the clip should descend by (between 2 and 6)
}
this.reset();
}
onClipEvent(enterFrame) {
if (this._y > 400) { // where 400 is the height of your movie
this.reset(); // start again from the top
}
this._y += this.speed;
}