I’m trying to update the Flash 5 actionscript on an old Deconcept file to at least Player 7 and AS 2.0. Here’s my updated code -
The snow flake movie clip:
onClipEvent(load) {
// mostly just initializing some vars
//var xSpeed = (random(10)+1)-5; // OLD CODE
var xSpeed = (Math.floor(((Math.random() * 10) +1)-5)); // left to right movement, all random
var a = 7; // vars for movement code, just makes is smoother
var d = 1.7; // same as above
var newX = _x;
var newY = _y;
if (this._name == "flake") { // this makes the original flake invisible (not really needed, but what the hell
this._visible = false;
}
}
onClipEvent(enterFrame) {
if (this._name <> "flake") { // this is so the original flake stays put
var changeXspeed = (Math.random() * 8) + 1; // random value to change the left to right motion of the flakes
if (changeXspeed == 5) {
xSpeed = ((Math.random() * 10) + 1) - 5;
}
newX += xSpeed;
newY += ySpeed;
if (this._y > 300) { // this removes the clip once it reaches a certain point
this.removeMovieClip();
}
}
myXspeed = ((this._x-newX)/a+myXspeed)/d; // this is just movement code to make is move smoother
myYspeed = ((this._y-newY)/a+myYspeed)/d;
this._x -= myXspeed;
this._y -= myYspeed;
}
And the controller movie clip:
onClipEvent (load) {
var counter = 1;
}
onClipEvent (enterFrame) {
if (counter < 70) {
//var makeItSnow = (random(3)==2) ? 1:0;
var makeItSnow = Math.floor(Math.random() * 2);// this determines how many flakes are created, make the random value higher for fewer flakes (a good idea if you have lots of other movement on the page)
//trace(makeItSnow);
if (makeItSnow) {// duplicate the main clip, position it randomly, then set the width and height to random values, then set the speed according to the size - that's it
duplicateMovieClip("_root.flake", "flake" + counter, counter);
myFlake = _root["flake" + counter];
myFlake._x = (Math.random() * 750) + 1;
myFlake._xscale = (Math.random() * 34) + 1;
myFlake._yscale = (Math.random() * 34) + 1;
myFlake.ySpeed = (myFlake._width + myFlake._height) / 2;
counter++;
}
} else {
delete this.onEnterFrame;
}
}
When I trace the different variables I don’t see any problems but the snow just isn’t visible. Anyone see any obvious mistakes?