ActionScript 2.0 :: Way To Make Health Decrease By Decimal / But Show Whole Number In Textbox

Jan 9, 2010

I am making a flash game for a school project, and I decided to make a stick fighting game.once the enemy attacks the player their health just drains. The only way I can fix it is if I have a decimal instead of a whole number, but I have the variable of the health in a text box to display the players current health and it doesn't look to good with a decimal number.So, I am wondering if there is a way to make the health decrease by a decimal, but show a whole number in the textbox.[code]

View 2 Replies


Similar Posts:


Can't Get Health Bar To Decrease / When Hitting Animation Occurs

Aug 21, 2009

I'm having problems with actions script in Flash 8.I'm trying to make a little side scrolling fighting game, i've got a character and an enemy which follows him and has an attack animation when close, but I can't get the health bar to decrease when the hitting animation occurs while in contact with the hero.[code]I put this script on an invisible square which appears during the attack animation, HERO is my hero's instance name and HP the health bar's. Whats suppose to happen is that the enemy goes for the attack animation which is of hitting the hero whith an axe, and when the invisible box hits the hero at that moment, the hp should go down..

View 1 Replies

ActionScript 2.0 :: Show Two Decimal Places Regardless Of The Number Itself?

Sep 12, 2004

how I can format numbers in Flash so that it will show two decimal places regardless of the number itself?

View 4 Replies

ActionScript 3.0 :: Force Show 2 Decimal Places In Number?

Nov 22, 2010

I have tried and tried but i cannot get a number to force show 2 decimal places.I have lots of different buttons and selection boxes that output a different value for 'sizePrice' and 'effectPrize'. An example can be seen below:

Code:
if (sizeSelectionBox.value=="size1") {
sizePrice=67.20;
calcTotalPrice();

[code]...

I need totalCost to always show 2 decimal places so if it is 60 it needs to say 60.00, if it is 67.2 it needs to say 67.20

View 4 Replies

ActionScript 3.0 :: Force Show 2 Decimal Places In Number

Nov 22, 2010

I have tried and tried but i cannot get a number to force show 2 decimal places.

I have lots of different buttons and selection boxes that output a different value for 'sizePrice' and 'effectPrize'. An example can be seen below:

Code:
if (sizeSelectionBox.value=="size1") {
sizePrice=67.20;
calcTotalPrice();

[Code]....

I need totalCost to always show 2 decimal places so if it is 60 it needs to say 60.00, if it is 67.2 it needs to say 67.20

I thought the *100/100 should do it but its no

View 2 Replies

ActionScript 3.0 :: Make A App Where The User Enters A Decimal Number?

Jul 3, 2009

I am rather new to actionscript and having some trouble. My goal is to make a app where the user enters a decimal number and the number of decimal places and the output is displayed in a dynamic text box. Here's what I have so far:

ActionScript Code:
go_btn.addEventListener(MouseEvent.CLICK,Display);
function round(num:Number, dp:int):Number {
var decimal:Number = Math.pow(10, dp);
trace(Math.round(decimals * num) / decimal)

[Code]...

View 1 Replies

ActionScript 2.0 :: Method To Check If A Number Is A Decimal Number?

Jan 20, 2006

there is any method to check if a number is a decimal number or not? i searched in the help-panel, but didn't found something.

View 6 Replies

Flash8 :: Random Number Decrease?

Oct 23, 2010

i have this script

Quote:

on (release) {
health -= 10;
if (health>500) {[code].........

I was wondering if there is a code i can use to replace the 10 with a random number between say 1-10.(Ergo when the script triggers the health is decreased with something between 1-10 instead of the set nr 10)

View 2 Replies

ActionScript 3.0 :: Number To Decrease By One On Keypress?

Mar 24, 2011

I want a number stoed in a variable to decrease by 1 everytime the right key is pressed. here is my code but it isnt working.[code]...

View 4 Replies

Add A Health Bar/percent Or Someway Of Health In A Shooter?

Sep 14, 2009

Im making a shooter. I want my player to have health. Its similar to galaga. The player instance is PlayerShip and the shot from the alien is AlienShotT i want 100 health and -10 health per alien shot.

View 1 Replies

ActionScript 2.0 :: Make A Script That Show Numbers Counting To A Certain Number?

Apr 22, 2005

Im trying to make a script that show numbers counting to a certain number.I want to start at 0 and then counting up to for example 52.

View 4 Replies

ActionScript 2.0 :: Defining A Function To Increase Or Decrease A Number?

Mar 24, 2006

1. The are two buttons

2. If you click the first one a number is increaded by 1

3. If you click the second one the same number gets decreased by 1

4. For each there is an IF statement which starts a certain action

I can't figure out how to make this work. The following script returns only one number and thus starts only on action:

function ClipSelector(i:Number):Number {
i++;
return i;

[Code].....

View 1 Replies

ActionScript 1/2 :: Make Health Bar Go Down?

Aug 18, 2010

Alright, so after some work and a lot of mistakes, I made a health bar for my game. (This is in Actionscript 2) Basically, the code is on my main character's .as file, there is var maxHealth : Number = 100; var health : Number = 100; and further down the line... _root.healthBar._width = (health/maxHealth) * 200;.As a result, when I change the var health number lower, the health bar goes lower. Sweet! It works! Now I was wondering if any of you guys could help me code it so an enemy can inflict damage upon the main character. I have tried many codes but they have all failed. if(this.hitTest(_root.Monster)) { } What would I put in the brackets?

View 3 Replies

ActionScript 3.0 :: How To Make A Health Bar

May 31, 2010

i am a newbie in AS3 or should i say a total noob in actionscripts and flash itself.Currently i need help on how to make a health bar.Basically i need to make a health that decrease over time when the mouse clicks on it. Meaning:Example when there are like 4 objects, A,B,C,D A and B are objects that help that player score points and C and D are objects that make the health bar goes down. By using mouse event, i must make it able to detect the clicking when the object is being clicked.

View 2 Replies

ActionScript 3.0 :: Make A Health Bar And Stamina Bar?

Dec 20, 2010

codes regarding on how to create a health bar and stamina barfor example when you move your character sideways the stamina bar decreases.

View 1 Replies

ActionScript 3.0 :: Increase & Decrease Operators - Count The Number Of Correct And Incorrect Answers

Jul 11, 2009

I'm using AS3 in timeline. I'm working on a multiplication game. The idea is to count the number of correct and incorrect answers and give the user a final count. I have several dynamic text boxes: box1 and box2 will multiply each other.box3 = input box; user inputs answerbox4 = message displaysbox5 = correct1; displays correct countbox6 = correct2; displays incorrect count buttonsbt_1 = checks answersbt_2 = resets problems PROBLEM:I CAN'T GET BOX6 COUNT THE INCORRECT ANSWERS. HOW CAN I FIX THIS PROBLEM?

[Code]...

View 3 Replies

ActionScript 2.0 :: Show Two Decimal Values?

Feb 11, 2010

I have some dynamic text fields. And i have assigned some two decimal values to them.eg._global.minqty = 10.00;total_cost.text = _global.mincost;but its showing me only 10. And i want to display 10.00.

View 1 Replies

ActionScript 2.0 :: Math Show Whole # + 1 Decimal?

Sep 9, 2008

I can't remember how to do this. I have a set of numbers that are esentailly like follows:

323.3434456764
4.349075639
5654.64547290477347

I need to truncate the number to show the whole number as well as the first decimal value. So like Math.floor, but truncating one decimal place.

View 1 Replies

ActionScript 2.0 :: Always Show 3 Decimal Places?

Sep 21, 2010

For example I could have 6 or 6.5 or 6.75 or 6.125 but I need to convert all to show zeros at the end if they are less than three decimal places. So it should output respectively,6.0006.5006.750or leave alone at 6.125 or some other three digit number.

View 6 Replies

ActionScript 1/2 :: Make A Health Bar - Doesn't Clear The Timer

Feb 25, 2010

I'm trying to make a health bar, it does down when you press a button. I used a timer. But it doesn't clear the timer, it just keeps on going.

[Code]....

View 5 Replies

How To Format Numbers To Show 2 Decimal Places

Sep 12, 2004

How I can format numbers in Flash so that it will show two decimal places regardless of the number itself?

View 7 Replies

ActionScript 3.0 :: Set Decimal In Floating Number

Nov 16, 2009

i have value of have long number after decimal. Now, I want to control in 3 digit after decimal. How could i do.

View 1 Replies

ActionScript 3.0 :: Set Decimal In Floating Number?

Nov 16, 2009

here i have value of have long number after decimal. Now, I want to control in 3 digit after decimal. How could i do

Ex:
Problem = 9.982540214587
Want = 9.982

View 3 Replies

ActionScript 3.0 :: Get Decimal Part As Whole Number?

Jun 27, 2011

I want to get decimal part of the number in this case 67 (number = 67 ) First problem is internal calculations

ActionScript Code:
var number:Number = 987123456.67;
var intNum:Number = Math.floor(number);
var decimal = parseFloat(String(number - intNum));
trace(decimal); //outputs 0.6699999570846558, instead of 0.67

I wonder is there a any way to doit besides using toString?

View 9 Replies

ActionScript 2.0 :: Rounding A Number To Have No Decimal?

Mar 22, 2012

I'm making a game where you level up, and then the amount of EXP you need to level up, gets higher. The problem is, if I have it so the amount of EXP needed to get to the next level just multiply by 2, it just gets to an absurdly high number, and I don't want that. I would rather have it multiply by 1.3 or 1.5, but the problem with that is that the right side of the decimal gets all ugly to something like "60.54902380".

how would I be able to round it so there's no decimal point, or at best just one number to the right?

View 2 Replies

ActionScript 2.0 :: Set A Number To 2 Decimal Places?

Aug 27, 2005

how do you set a number to 2 decimal places??

View 7 Replies

ActionScript 2.0 :: Rounding Off Decimal Number?

Sep 12, 2006

How can I round off a decimal number upto say three decimal places? The number comes as an output value like 0.98765e^7 for the statement outputvalue = 0.8678/InputValue. How can I make the output value rounded off as 0.988e^7?

View 7 Replies

ActionScript 2.0 :: How To Get Simple Decimal Number

Feb 22, 2010

I want to get rounded number
Example:
I want to get full number I write
Code:
cas=15.02
int(cas)
and I get 15

But when I write these
Code:
cas=15.02
lol=cas - int(cas)
trace(lol)
I get 0.0199999999999996 instead of 0.02. I need to get only decimals so that i will be able to write 15.02 like 15:02 or 1.2 like 01:20. I need to write numbers like in digital clock.

View 8 Replies

ActionScript 2.0 :: Display Number To 2 Decimal Places?

Sep 13, 2008

I am totally confused about this one. I am trying to display a number as x.xx, but I'm having problems! The number has 0, 1 or 2 decimal places, so I have an if else to add '0' or '.00' on the end if there are 1 or 0 decimal places respectively.[code]...

View 3 Replies

ActionScript 2.0 :: Count Number Of Decimal Places?

Feb 13, 2012

why does this not work for counting the number of decimals?

Code:
var num:Number = 4.321;
counter=0
while (num%1!=0) {

[Code]....

View 0 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved