-
Call an animation on mouse over
I have gotten hold of some code that animates some balloons, but they kick off as soon as you enter the screen.
I have some buttons lined up and was owndering if somebody could take a look at the following code and make it work so that when I roll over a button the animation starts.
Code:
snowNumber = 40;
var flakes:Array = new Array("snow", "flake2", "flake3","flake4","flake5")
for (i=0; i<snowNumber; i++) {
newSnow = _root[flakes[random(flakes.length)]].duplicateMovieClip("snow"+i, i);
newSnow._x = Math.random()*Stage.width;
newSnow._y = Stage.height+Math.random()*300;
newSnow.maxSnowSpeed = Math.random()*4;
newSnow.wind = Math.random()*6;
newSnow._xscale = newSnow._yscale = Math.random()*60+40
newSnow.swapDepths(newSnow._xscale)
prevSnow = newSnow;
newSnow.onEnterFrame = function() {
//this._rotation -= this.maxSnowSpeed+1;
if(this._y<-50 || this._x>Stage.width+50 || this._x<-50){
this._y = Stage.height+Math.random()*300;
this._x = Math.random()*Stage.width;
} else {
this._y -= this.maxSnowSpeed+1;
this._x += this.wind-4;
}
//this._alpha = this.alpha;
};
}
Thanks
Lee
-
The animation goes around and around continually, so can it be changed so that it only does it once or twice maybe.
Be great if anybody can help.
Thanks
-
tried putting the keyframe with all that code in on the second frame of a movie clip and on roll over the movie clip moved to the second frame in the hope that it would play the animation, but it didnt.
The balloons showed up but the code didnt seem to work
-
Maybe you can adapt this to what you are trying to do...
Code:
function doSnow(snowNumber) {
var flakes:Array = new Array("snow", "flake2", "flake3", "flake4", "flake5");
for (i = 0; i < snowNumber; i++) {
newSnow = _root[flakes[random(flakes.length)]].duplicateMovieClip("snow" + i, i);
newSnow._x = Math.random() * Stage.width;
newSnow._y = Stage.height + Math.random() * 300;
newSnow.maxSnowSpeed = Math.random() * 4;
newSnow.wind = Math.random() * 6;
newSnow._xscale = newSnow._yscale = Math.random() * 60 + 40;
newSnow.swapDepths(newSnow._xscale);
prevSnow = newSnow;
newSnow.onEnterFrame = function() {
//this._rotation -= this.maxSnowSpeed+1;
if (this._y < -50 || this._x > Stage.width + 50 || this._x < -50) {
//this._y = Stage.height + Math.random() * 300;
//this._x = Math.random() * Stage.width;
this.removeMovieClip();
} else {
this._y -= this.maxSnowSpeed + 1;
this._x += this.wind - 4;
}
//this._alpha = this.alpha;
};
}
}
btn1.onRollOver = function() {
doSnow(40);
};
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
|