[Tools][Expand/Collapse All]Note that automatic extraction of ActionScript 3 is still pretty much unsupported by swfchan. AS1/AS2 works okay most of the time.Frame 1 (1.54 KiB) ●
function makeBalls(numBalls) {
var _local1 = _root;
var _local2 = numBalls;
j = 0;
while (j < 20) {
_local1["mc_ball" + j].removeMovieClip();
j++;
}
i = 0;
while (i < (_local2 - 1)) {
mc_ball.duplicateMovieClip("mc_ball" + i, i);
_local1["mc_ball" + i]._x = initX;
_local1["mc_ball" + i]._y = initY;
_local1["mc_ball" + i].velocityY = 10 * Math.random();
_local1["mc_ball" + i].velocityX = 10 * Math.random();
_local1["mc_ball" + i].velocityZ = 10 * Math.random();
_local1["mc_ball" + i].oldX = initX;
_local1["mc_ball" + i].oldY = initY;
_local1["mc_ball" + i].oldZ = initY;
_local1["mc_ball" + i].time = 1;
i++;
}
}
var time;
var velocity;
var blnHasBounced;
var previousY;
var previousX;
var mGravity;
var mFriction;
var blnChanged;
mc_ball._visible = false;
var initX = 20;
var initY = 20;
if (!blnChanged) {
sliderFriction.slideBar._x = 190;
sliderGravity.slideBar._x = 50;
sliderBalls.slideBar._x = 120;
}
mFriction = sliderFriction.slideBar._x / 200;
mGravity = sliderGravity.slideBar._x / 10;
mBalls = sliderBalls.slideBar._x / 10;
makeBalls(mBalls);
sliderGravity.onEnterFrame = function () {
gravity = this.slideBar._x / 10;
_root.mGravity = gravity;
this.txtCounter = gravity;
};
sliderFriction.onEnterFrame = function () {
friction = this.slideBar._x / 200;
_root.mFriction = friction;
this.txtCounter = friction;
};
sliderBalls.onEnterFrame = function () {
balls = Math.floor(this.slideBar._x / 10);
_root.mBalls = balls;
this.txtCounter = balls;
};
Instance of Symbol 13 MovieClip "sliderGravity" in Frame 1 (21 B)
/* no clip actions */
Instance of Symbol 13 MovieClip "sliderFriction" in Frame 1 (21 B)
/* no clip actions */
Instance of Symbol 13 MovieClip "sliderBalls" in Frame 1 (21 B)
/* no clip actions */
Instance of Symbol 2 MovieClip [mc_ball] "mc_ball" in Frame 1 (1.09 KiB) ●
onClipEvent (enterFrame) {
velocityY = (_root.mGravity * time) + velocityY;
velocityX = velocityX;
velocityZ = velocityZ;
newY = oldY + (velocityY * time);
newX = oldX + (velocityX * time);
newZ = oldZ + (velocityZ * time);
trace(velocityY);
if (Math.abs(velocityY) < 0.001) {
velocityY = 0;
}
if (Math.abs(velocityX) < 0.001) {
velocityX = 0;
}
if (Math.abs(velocityZ) < 0.001) {
velocityZ = 0;
}
if (newY >= 200) {
newY = 200;
velocityY = -1 * velocityY;
velocityX = velocityX * _root.mFriction;
velocityZ = velocityZ * _root.mFriction;
}
if (newY <= 5) {
newY = 5;
velocityY = -1 * velocityY;
}
if (newX >= 445) {
newX = 445;
velocityX = -1 * velocityX;
}
if (newX <= 5) {
newX = 5;
velocityX = -1 * velocityX;
}
if (newZ >= 100) {
newZ = 100;
velocityZ = -1 * velocityZ;
}
if (newZ <= 5) {
newZ = 5;
velocityZ = -1 * velocityZ;
}
oldY = newY;
oldX = newX;
oldZ = newZ;
this._alpha = ((newZ / 100) * 30) + 70;
this._height = ((newZ / 100) * 8) + 2;
this._width = ((newZ / 100) * 8) + 2;
this._y = newY;
this._x = newX;
}
Frame 2 (8 B)
stop();
Symbol 5 Button (52 B)
on (press) {
blnChanged = true;
gotoAndPlay (1);
}
Symbol 13 MovieClip Frame 1 (222 B)
this.slideBar.onPress = function () {
var _local1 = this;
startDrag (_local1, false, 0, _local1._y, 200, _local1._y);
};
this.slideBar.onRelease = (slider.slideBar.onReleaseOutside = function () {
stopDrag();
});