# As 2 equations

**URL:** https://forum.kirupa.com/t/as-2-equations/266035
**Category:** Uncategorized
**Created:** [July 15, 2008, 5:45pm UTC](https://forum.kirupa.com/t/as-2-equations/266035 "2008-07-15T17:45:17Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![spyderfx](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@spyderfx](https://forum.kirupa.com/u/spyderfx)
#### Post date: [July 15, 2008, 5:45pm UTC](https://forum.kirupa.com/t/as-2-equations/266035/1 "2008-07-15T17:45:17Z")

</div>

does anyone know a tutorial about writing equations in AS 2. I’m not sure what the format is.

---

<div class="post-metadata">

### Author: ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)
#### Post date: [July 15, 2008, 9:52pm UTC](https://forum.kirupa.com/t/as-2-equations/266035/2 "2008-07-15T21:52:36Z")

</div>

?? what kind of equations …

---

<div class="post-metadata">

### Author: ![spyderfx](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@spyderfx](https://forum.kirupa.com/u/spyderfx)
#### Post date: [July 15, 2008, 10:00pm UTC](https://forum.kirupa.com/t/as-2-equations/266035/3 "2008-07-15T22:00:39Z")

</div>

really simple ones that i should know ☹

its been too long since i’ve tried programming a game

i can’t even remember how to subtract from a variable. i’m trying to set var lifes = 3 and then for every wrong button pressed var lifes gets -1 from it. i was trying to do something like

life -1 -= life

its wrong though

---

<div class="post-metadata">

### Author: ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)
#### Post date: [July 15, 2008, 10:01pm UTC](https://forum.kirupa.com/t/as-2-equations/266035/4 "2008-07-15T22:01:01Z")

</div>

```auto
lifes -= 1;

```

or

```auto
lifes--;

```

or

```auto
--lifes;

```

or

```auto
lifes = lifes - 1;

```

---

<div class="post-metadata">

### Author: ![spyderfx](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@spyderfx](https://forum.kirupa.com/u/spyderfx)
#### Post date: [July 15, 2008, 10:10pm UTC](https://forum.kirupa.com/t/as-2-equations/266035/5 "2008-07-15T22:10:08Z")

</div>

so that first one will subtract 1 from lifes? also if you don’t mind explaining, what is the – do specifically?

---

<div class="post-metadata">

### Author: ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)
#### Post date: [July 15, 2008, 10:21pm UTC](https://forum.kirupa.com/t/as-2-equations/266035/6 "2008-07-15T22:21:08Z")

</div>

> so that first one will subtract 1 from lifes?

Yes.

> also if you don’t mind explaining, what is the – do specifically?

It subtracts 1 from a number. If you use it before the variable, then the variable evaluates to that value minus 1. If you use it after the variable, the variable evaluates to whatever it was before you tried to subtract one, but its value is one less after it has been evaluated.

```auto
var q = 1.4;
trace(q++); // 1.4
trace(q);	// 2.4

q = 1.4
trace(++q); // 2.4
trace(q);	// 2.4

trace((q++) + ' ' + q); // 2.4 3.4

```

---

<div class="post-metadata">

### Author: ![spyderfx](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@spyderfx](https://forum.kirupa.com/u/spyderfx)
#### Post date: [July 15, 2008, 10:25pm UTC](https://forum.kirupa.com/t/as-2-equations/266035/7 "2008-07-15T22:25:48Z")

</div>

ah cool! thanks

---

<div class="post-metadata">

### Author: ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)
#### Post date: [July 16, 2008, 2:43am UTC](https://forum.kirupa.com/t/as-2-equations/266035/8 "2008-07-16T02:43:43Z")

</div>

although it’s probably a good idea to note that --variable subtracts BEFORE the variable is read, and variable-- subtracts AFTER it is read;

```auto
var myVariableBefore:Number = 0;
trace(--myVariableBefore); // will thus output -1
var myVariableAfter:Number = 0;
trace(myVariableAfter--); // will thus output 0

```

EDIT::: SORRY, completely missed the second half of your last post somehow :x
