Flash help

Miscellaneous Forums/General Discussion/Flash help

Hi guys.. not blitz releated but I am sure some of you use flash/action script.

I am lookig to create a simple count down timer in flash (AS 2.0), but I cant seem to store a variable.. or to stop flash remaking the variable.

this what I have;

1. Made a dynamic text box.. called it "counterINS"
2. set FPS on movie to 1
3. frame 1 =
	var timetoo_mins = (6) // mins
	var newtime = (timetoo_mins * 60); // get seconds
	trace("loaded vars");
	
	gotoAndPlay(2);

4. frame 2 =
	if (newtime > 0) {
		newtime = newtime - 1;
		trace(newtime);
	}
	_root.counterINS.text = newtime; // update text box

	gotoAndPlay(2);

What this should do is decrease newtime by 1 every seconds 360>359>358>357 etc ... instead it loops through both frames reset newtime back to 360.. ignoring my gotoAndPlay(2) command?

My trace output is =

loaded vars
359
loaded vars
359
loaded vars
359
loaded vars
359
loaded vars
359

What am I doing wrong? I am new to flash.

You should probably use intervals instead but try adding a frame 3, and moving the gotoAndPlay(2); line from frame 2 to frame 3.

I may be wrong, but I think using "var" keyword in front of your variable makes it a local variable aswell. 'This frame only'

Anyway, use intervals instead.

var interval:Number = setInterval(<function to run each interval>, <millisecs between each interval>);

or a one-shot timer:
var timer:Number = setTimeout(<function>, <millisecs>);

the timeout function will clear itself when its done, but you can do it yourself with clearTimeout(timer) if you want to.

These functions are threaded aswell


EDIT: Also, Flash tends to drop certain requests to the timeline controls such as play, gotoandplay(num) and so on if they happen too close to eachother, so add a delay if this happens ;)

Sorry coffeedotbean, this is off-topic but either your email doesn't work or you don't check it.

You mention on this site: http://cupertino.awardspace.com/
that you don't have source or demo for Push'Em. I got a beta and a demo of Push'Em from archive.org off your old sites. I wonder if you're still looking for this.
Also, I notice all the file links are gone on that site now, which seems a shame.

thanks for the flash suggestions.. ill try that later when im at home.

Mark I dont check that email address.. i should do but would probably crash my system with all the spam, not checked that for a good 12 months atleast.

thanks for the link to that site.. never knew it existed..the links on the site are dead =d looks like rapid share delete file after 30days of no activity. Ill set it as my weekend tak to get the back up and running... ill have more failed and abandoned projects to add =D

Do you have or want a copy of Push'Em then?

var timetoo_mins
if (timetoo_mins == undefined) {
timetoo_mins = 6;
}
var newtime = (timetoo_mins * 60); // get seconds
trace("loaded vars");
gotoAndPlay(2);

Thanks Ziggy.

Mark yes please send the demo if you can to coffeedotbean AT googlemail DOT com

Well that email doesn't seem to exist.

hi mark

it does trust me =D

coffeedotbean AT googlemail DOT com