Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 1st, 2013, 06:52 AM
Kilza13 Kilza13 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 1 Kilza13 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 27 sec
Reputation Power: 0
Using a timer as a score system

Hey DevShed'ers!

I've recently started using Flash (Action Script 2.0). For one of the projects at school they are getting us to essentially make our own puzzle games from scratch.

On the frame at which the puzzle sits I have a big button that says start. Clicking this button makes the first puzzle piece appear on stage and when you place it within set coordinate the next puzzle piece is moved on stage and so on until piece 9; the final piece were it goes to the next frame - The score frame/winning frame?

Pretty simple, but another function the start button has is it starts a timer (timer is a var name set to a dynTextbox). Essentially I want it so that when the final piece of the puzzle is placed the timer is stopped and the time that it stopped on is saved and put on the score tab, plus stored in a var or something so that I can use it later.

I made the timer, but when I sorta figured out how to make it trace the last number in the timer I broke it and have hit a wall with no idea what to do.

Here are my codes:


START button -
Code:
on (release){
	timer = 0; //Sets the variable to 0	
	
	countup = function(enabled:Boolean){ //Creating the countup function
		if (enabled == true) {
			timer += 1; //timer function
		} else {
			timer = timer;
		}
		_root.btn_llamastart.enabled = false;
	}
	
}
on (release){
	countupInterval = setInterval(countup,1000); //Set the counting internval to X
	
	setProperty(_root.llama_p1, _x, "640.80");
	setProperty(_root.llama_p1, _y, "164.30");
}


Piece 9 (last piece) -
Code:
on (press) { //On event 'press'
	startDrag(this); //Starts draging object }
	
}

on (release) {
	stopDrag(); //Stops dragging
    if ((this._x >0) && (this._x < 30) && (this._y >260) && (this._y <360)) {  // if puzzle pieces is within these set boundaries
    	setProperty(this, _x,"14.60"); //Set objects coordinates to set ones
    	setProperty(this, _y,"314.25"); //Set objects coordinates to set ones
		gotoAndStop(4);
		var totalTime:Number = _root.timer;
		trace(totalTime);
		countup(false);
    }
}


If someone could help me do what I want to achieve, that would be awesome.

Cheers!

edit : I want to use the last time to be put on a leader board kind of thing as well. Less amount of time taken to most.

Reply With Quote
  #2  
Old March 1st, 2013, 02:41 PM
Frank Grimes's Avatar
Frank Grimes Frank Grimes is offline
Plays with fire
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2003
Location: Outside looking in
Posts: 894 Frank Grimes User rank is Second Lieutenant (5000 - 10000 Reputation Level)Frank Grimes User rank is Second Lieutenant (5000 - 10000 Reputation Level)Frank Grimes User rank is Second Lieutenant (5000 - 10000 Reputation Level)Frank Grimes User rank is Second Lieutenant (5000 - 10000 Reputation Level)Frank Grimes User rank is Second Lieutenant (5000 - 10000 Reputation Level)Frank Grimes User rank is Second Lieutenant (5000 - 10000 Reputation Level)Frank Grimes User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 4 h 47 m 34 sec
Reputation Power: 95
I'm a bit rusty with AS2, but try this:

Code:
var timer:Number=0;
var counter;


myButton.onRelease=function() {
  setProperty(_root.llama_p1, _x, "640.80");
  setProperty(_root.llama_p1, _y, "164.30");

  myCounter=setInterval(countup,1000);
}

function countup() {
  timer++;
}


Be sure to clearInterval(myCounter) when the last piece is dropped.
__________________
“Be ashamed to die until you have won some victory for humanity.” -- Horace Mann

"...all men are created equal." -- US Declaration of Independence

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > Using a timer as a score system

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap