Welcome Guest [Log In] [Register]
Welcome to Brackenwood. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Timer Function; Help, it doesn't work.
Topic Started: Mar 21 2006, 01:43 PM (149 Views)
Catalist
Member Avatar
Brackenwood Member
Ok, here's the deal. I'm working on a small game, and the first step is going to be this, the timer.
I've made a little script that turns my imput in seconds into frames, and the movie is running at 36 fps.
so every 2 second is 24 frames, or -1 from every 12 seconds. I'm doing it this way because the game is to have no real value, but only that of helping me learn. And right now I don't really want to get into setInterval.
So, now that I've explained it, could someone help me figure out why this doesn't work.
I have a bar, 5 pixles high and 1 wide, with the registration point on the left.
but this doesn't make the bar the correct width.
Code:
 
root.sec.text=1;
_root.timed.text=_root.sec.text*36;
_root.bar1.text=(_root.timed.text)/530;
_root.bar2.text=_root.bar1.text*530;
_root.bar._width=bar3;
_root.ab.text=text(_root.bar1.text)

36 being the fps,
530 being the area I would like the bar to take up at the most.
I'm still not quite sure how the time will deteriorate, but I will figure that out.
Right now I just want to know why the bar will now become longer...
Thanx if you can help. :wbitey:
Offline Profile Quote Post Goto Top
 
Mr. Jiggmin
Member Avatar
made of tulips
I'm not exactly sure what you're trying to do with all of those text boxes in your code, but maybe this will help:

Code:
 
//creates a variable that will keep track of the time
var time:Number = 0;
//the code in the onEnterFrame runs every frame
onEnterFrame = function () {
//adds one thirty-sixth of a second to the time every frame
time += (1/36);
//sets the text box to the time
timed.text = time;
//makes the bar shorter as time goes on
bar._width = 530-time;
};
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Actionscript · Next Topic »
Add Reply