Announcement

User registrations are currently disabled due to high spam traffic.

#1 18/07/08 10:27pm

tenjimaru
Moderator
From: SD-CA
Registered: 30/03/08
Posts: 679

help, whats the code fro

ok so i'm trying to make a timer, that starts from 0 and goes up by 1 sec. i think you have to put a text bos and then set a avriable to it, but i don't know what to type in the action script box, I'm using flash mx 2004

I think hot mine pursuit uses something like that....

thanks in advance.

PS: thats the one last thing i need to add to my new locoroco bounce version, so it would really help if you helped as fast as posible, but no rush ^.^


[i]cookie Tenebra Crystallis.. Released!
Portable Fishing 2012 Released!
Find Them In The 'Flash Games' Section of The Forums[/i]

Offline

 

#2 18/07/08 11:17pm

69corvette
That one guy.
From: Not Palmdale, CA
Registered: 01/02/08
Posts: 281

Re: help, whats the code fro

Code:

var interval_amount = .1; // how often to update timer (in seconds)
var timer:Number = 0;  //initialize timer
this.createTextField("timer_txt", 1, 100, 100, 300, 100); //create text field
updateText();

function updateTimer():Void { //update function
    timer += interval_amount; //add to the time
    updateText();
}

function updateText(){
    timer_txt.text = timer; //update text
}

function startTimer(){ //function to initialize interval
    interval_amount_in_ms = (interval_amount * 1000); //change interval_amount to ms
    var interval:Number = setInterval(updateTimer, interval_amount_in_ms); //interval that updates every "x" ms.
}

startTimer(); // start the timer

This should work.
I broke it down in to different functions to make it simpler.
I also put comments in so you could understand.


[img]http://img221.imageshack.us/img221/8990/smallersigcopylb1.jpg[/img]

Offline

 

#3 19/07/08 12:00am

tenjimaru
Moderator
From: SD-CA
Registered: 30/03/08
Posts: 679

Re: help, whats the code fro

ok, thank you so much, this will help alot.

one more thing how do imake the timer stop, when it reaches a frame?

Last edited by tenjimaru (19/07/08 12:08am)


[i]cookie Tenebra Crystallis.. Released!
Portable Fishing 2012 Released!
Find Them In The 'Flash Games' Section of The Forums[/i]

Offline

 

#4 19/07/08 3:12am

crimsonhotsun
Hardcore Member
Registered: 30/03/08
Posts: 96

Re: help, whats the code fro

Code:

if(_root._currentframe==23)
{
    clearInterval(interval);
}

at least I think that's it.


[img]http://img101.imageshack.us/img101/9094/20707804nc6.png[/img]

My humble forums: [url=http://hologram.zxq.net/forums/]VirtualWorldForums[/url]

Offline

 

#5 19/07/08 7:03am

mental_atom
Regular Member
Registered: 11/06/08
Posts: 64
Website

Re: help, whats the code fro

theres a much simpler way. make a movieclip and put a keyframe on the frame for fps e.g on 18fps put  a keyframe on frame 18. on the keyframe put:

Code:

_root.timer -=1

then make a dynamic text box variable "timer". then make another small movie clip

Code:

onClipEvent(enterFrame){
if(_root.timer == 0){
_root.gotoAndStop(frame);
}
}

that should work


[img]http://i25.tinypic.com/n4wlcm.jpg[/img]

Offline

 

#6 19/07/08 8:56am

lilmb
Serious Addict
From: Latvia
Registered: 22/06/08
Posts: 305

Re: help, whats the code fro

This code could work with Liveswif?

Offline

 

#7 20/07/08 12:19am

Zuriki
Flash Dev (The Lazy One)
From: Manchester
Registered: 18/01/08
Posts: 755
Website

Re: help, whats the code fro

LiveSwif doesn't support Dynamic text boxes people.


[img]http://img134.imageshack.us/img134/9129/headerxt2.png[/img]
[url=http://zuriki.co.nr/project/traveller/][img]http://i28.tinypic.com/2vspafo.png[/img][/url]
[url=http://zuriki.co.nr]Zuriki - PSP Flash Games[/url]

Offline

 

#8 20/07/08 5:13am

tenjimaru
Moderator
From: SD-CA
Registered: 30/03/08
Posts: 679

Re: help, whats the code fro

thanks, i'll see which code suits best to the game...

Ps: Tomorrow Big Day, I may have it ready by tomorrow (the game)


[i]cookie Tenebra Crystallis.. Released!
Portable Fishing 2012 Released!
Find Them In The 'Flash Games' Section of The Forums[/i]

Offline

 

#9 20/07/08 5:50am

69corvette
That one guy.
From: Not Palmdale, CA
Registered: 01/02/08
Posts: 281

Re: help, whats the code fro

@mental_atom
Frame based timers are not better as they may seem simpler.  Since the psp flash player tends to not play exactly "x" fps, it won't make an accurate timer.  Where as a getTimer() or interval function will be time based not frame based.


[img]http://img221.imageshack.us/img221/8990/smallersigcopylb1.jpg[/img]

Offline

 

#10 20/07/08 6:32am

mental_atom
Regular Member
Registered: 11/06/08
Posts: 64
Website

Re: help, whats the code fro

oh ok. worked fine for me before tho


[img]http://i25.tinypic.com/n4wlcm.jpg[/img]

Offline

 

#11 20/07/08 10:47am

Zuriki
Flash Dev (The Lazy One)
From: Manchester
Registered: 18/01/08
Posts: 755
Website

Re: help, whats the code fro

69corvette wrote:

@mental_atom
Frame based timers are not better as they may seem simpler.  Since the psp flash player tends to not play exactly "x" fps, it won't make an accurate timer.  Where as a getTimer() or interval function will be time based not frame based.

Yeah but then if you get major lag and it helps you survive something really difficult that should be like 3 seconds long and instead it is 10 due to lag, you get 7 extra points or whatever there.


[img]http://img134.imageshack.us/img134/9129/headerxt2.png[/img]
[url=http://zuriki.co.nr/project/traveller/][img]http://i28.tinypic.com/2vspafo.png[/img][/url]
[url=http://zuriki.co.nr]Zuriki - PSP Flash Games[/url]

Offline

 

#12 20/07/08 1:58pm

lilmb
Serious Addict
From: Latvia
Registered: 22/06/08
Posts: 305

Re: help, whats the code fro

Zuriki wrote:

LiveSwif doesn't support Dynamic text boxes people.

sad LiveSwif sucks. But for beginning it is normal.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson