| //action script placed on "movement" button
//key controls to initiate car and barrel movement
on (keyPress "<Left>") {
_root.moveLeft();
_root.screechSound.attachSound("screech2.wav");
_root.screechSound.setVolume(25);
_root.screechSound.start();
}
on (keyPress "<Right>") {
_root.screechSound.attachSound("screech2.wav");
_root.screechSound.setVolume(25);
_root.screechSound.start();
_root.moveRight();
}
on (release) {
_root.screechSound.stop();
}
//action script on frame 1 of movie
//create sound variables
this.createEmptyMovieClip("soundContainer1", 2);
var carSound = new Sound(this.soundContainer1);
this.createEmptyMovieClip("soundContainer2", 3);
var screechSound = new Sound(this.soundContainer2);
this.createEmptyMovieClip("soundContainer3", 4);
var radioSound = new Sound(this.soundContainer3);
//start background sound
carSound.attachSound("cardriving.wav");
carSound.setVolume(60);
carSound.start();
//loop background car sound
carSound.onSoundComplete = function() {
carSound.start();
};
//set variables for horizontal movement
var Lspeed = 25;
var Rspeed = 25;
var carRspeed = 25;
var carLspeed = 25;
//centers the barrel
function centerOrange() {
orange._x = 350;
}
//moves car right and barrel left
function moveRight() {
_root.orange._x -= Rspeed;
_root.car._x += carRspeed;
_root.car.steeringwheel.wheel._rotation += 25;
}
//moves car left and barrel right
function moveLeft() {
_root.orange._x += Lspeed;
_root.car._x -= carLspeed;
_root.car.steeringwheel.wheel._rotation -= 25;
}
onEnterFrame = function () {
// stops barrel at right edge
if (_root.orange._x>750) {
Rspeed = 0;
} else {
(Rspeed=25);
}
// stops barrel at left edge
if (_root.orange._x<0) {
Lspeed = 0;
} else {
(Lspeed=25);
}
// centers barrel when it reaches the car
if (orange.barrel1._y == 100) {
centerOrange();
}
// stops car at left edge
if (car._x<150) {
carLspeed = 0;
} else {
(carLspeed=25);
}
// stops car at right edge
if (car._x>600) {
carRspeed = 0;
} else {
(carRspeed=25);
}
}
//action script placed on "barrel4" movie clip stored in the library
//varriables for barrel postion and scale control
var xPos=0;
var yPos = 100;
var scale = 1;
//This function animates the image
onEnterFrame = function () {
yPos += 5;
scale += 5;
if (yPos>300) {
var xstart = new Array(-200, -100, 0, 100, 200);
var x = Math.random();
x = (xstart.length-1)*x;
x = Math.round(x);
xPos = xstart[x];
yPos = 100;
scale = 1;
}
character(xPos, yPos, scale);
}
//This function creates the image
function character(xPos, yPos, scale) {
attachMovie("barrel", "barrel1", 1);
barrel1._x = xPos;
barrel1._y = YPos;
barrel1._xscale = scale;
barrel1._yscale = scale;
}
|