473,385 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

can you help make this drive() function work?

saputello
hello, hello, hello

can anyone see the problem with this drive() function? i can't get it to work!

class Car {
// properties
public var mc:MovieClip;
private var acceleration:Number;
private var topSpeed:Number;
private var currentSpeed:Number;

public function Drive() {
if (currentSpeed<topSpeed) {
currentSpeed += acceleration;
mc._x -= currentSpeed;


} else if (currentSpeed>=topSpeed) {
currentSpeed == topSpeed;
}
}
/* ------------------------------------------------------------ */

// constructor
public function Car() {
var currentSpeed = 0;
var acceleration = Math.floor(Math.random()*3)+3;
var topSpeed = Math.floor(Math.random()*50)+50;

}
}


here's the script i have attached to the 1st frame of the movie:


var redCar:Car = new Car();
var yellowCar:Car = new Car();
var blueCar:Car = new Car();


// assign a movieclip to each car
redCar.mc = redCar_mc;
yellowCar.mc = yellowCar_mc;
blueCar.mc = blueCar_mc;


// go button functionality
go_btn.onRelease = function() {
_root.onEnterFrame = function() {
// tell all cars to Drive() forward, until one wins
redCar.Drive();
blueCar.Drive();
yellowCar.Drive();

if (redCar.mc._x <= finishLine_mc._x) Win("Red car");
if (blueCar.mc._x <= finishLine_mc._x) Win("Blue car");
if (yellowCar.mc._x <= finishLine_mc._x) Win("Yellow car");

}
}


function Win(whichCar:String) {
// stop all cars
_root.onEnterFrame = null;

// disable Go button
go_btn.onRelease = null;

// declare the victor!
win_txt.text = whichCar + " is the winner!";



thank you thank you thank you!
Apr 14 '08 #1
0 1438

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Randi | last post by:
Hi, Thanks David and I got that to work, I guess I still need to get it to work using the arrays and the selectedIndex property. I have to use an alert box that shows the total price like: The...
3
by: P Wolpert | last post by:
This is my first post. I hope I don't sound stupid. I have a script conflict when I put two scripts on one page. Both scripts will work if I use one at a time but the menu button script will not...
0
by: besaar | last post by:
i got the current project that got the serial no.of a hard disk for software protection but i got an error,if u solve it send me,thanx alllllll. 1.file1 Option Strict On Option Explicit On...
5
by: Maria Joćo | last post by:
I have a table with one field that ia a hyperlink to a pdf file that opens a specific file. Since these files are very big, I would need to change the hyperlink path, so that I could send the...
8
by: Lauren Wilson | last post by:
Hi Folks, We have a solid, five year old Access app that is suddenly behaving oddly after conversion to Access 2002/2003 format. Everything seems to run OK except for a few oddities. The code...
1
by: Todd | last post by:
OK, I created a .htm page within a new Web solution: -------------------------------------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head>...
6
by: Lucas Cowald | last post by:
Hi, I need to RUN/execute a Command-Line command from an ASP page. This is the command: sse45.exe -i k:\o\2.wmv -o k:\o\2.shh -w 128 -df 0 -m 2 -p Can you show me a code how to run this...
12
by: JLW | last post by:
I cannot get this to work correctly: File.Create("\\.\PHYSICALDRIVE0") or File.Create("\\.\Tape0") I've been searching for the better part of a week for this one. Thanks,
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.