# This is not working, why?

**URL:** <https://forum.kirupa.com/t/this-is-not-working-why/17902>\
**Category:** flash\
**Created:** [April 10, 2003, 4:53pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902 "2003-04-10T16:53:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Didiusthegreat](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@Didiusthegreat](https://forum.kirupa.com/u/Didiusthegreat)\
**Post date:** [April 10, 2003, 4:53pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/1 "2003-04-10T16:53:57Z")

</div>

Why is this not working

I have 3 inputs, and 3 dynamic text boxes,

a , b, e are input boxes, d, c and f are output  
But f is not working?

[AS]  
a = 0;  
b = 0;  
e = 0;  
\_root.onEnterFrame = function() {  
c = a\*b;  
d = c + ((c/100)\*21);  
f = e + ((e/100)\*21);  
}  
[/AS]

If nessecary I will give the fla…

Anyone?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 10, 2003, 5:14pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/2 "2003-04-10T17:14:29Z")

</div>

i’m not sure but i think flash doesnt show the ‘0’ variable…  
Try with non null variables for a,b and e and check if it works better…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 10, 2003, 5:22pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/3 "2003-04-10T17:22:00Z")

</div>

“a” and “b” work?

Wait, I’ve posted the fla

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 10, 2003, 5:26pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/4 "2003-04-10T17:26:30Z")

</div>

Oops, wrong one

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 10, 2003, 5:59pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/5 "2003-04-10T17:59:41Z")

</div>

what do those return to you?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 10, 2003, 8:18pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/6 "2003-04-10T20:18:03Z")

</div>

Well look at it…

a = 0  
b = 0  
e = 0  
c = a\*b

Well if a AND b are both 0, then 0\*0 will return 0.

SO d = c+((c/100)\*21); will return d = 0+((0/100)\*21);

And f = e+((e/100)\*21); will return f = 0+((0/100)\*21);

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 10, 2003, 10:01pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/7 "2003-04-10T22:01:06Z")

</div>

well duh… 😛 I know that. I figured that they weren’t returning the right thing so since they seem like they are supposed to be returning 0 then they aren’t… you get it?

I did pass Calculus… i can add and multiply :):):P:trout:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 10, 2003, 10:04pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/8 "2003-04-10T22:04:33Z")

</div>

Oh… haha Jubba, I wasn’t replying to your reply… although now I see it does look like that…ooooops.

I was responding to Didius on why it wasn’t working, because all it will return is 0, so how will it work?

Since his example file didn’t work (supposing he is on a Mac since there are issues with attaching .fla files when you use a mac…zipping them fixes that) I couldn’t check out what he was doing, so I assumed this was the issue.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 10, 2003, 10:07pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/9 "2003-04-10T22:07:29Z")

</div>

i see… interesting… ok then. 🙂

he’ll have to come back and give us a better file!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 12, 2003, 4:31pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/10 "2003-04-12T16:31:36Z")

</div>

Alright, I’m back

I’m not a mac user lost, The file was just enormous and my modem kind of crashed.

Anyway, here is the right file…

I’ll gues you will see the problem right away…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 12, 2003, 8:38pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/11 "2003-04-12T20:38:04Z")

</div>

Well I can’t say as I do see your problem.

The only problem I can see is that

a = 0;  
b = 0;  
e = 0;

If they all equal 0, then

c = a\*b;  
d = c+((c/100)\*21);  
f = e+21;

Will all be equal to 0 as well :-\

And I don’t get why you run it onEnterFrame :-\

What exactly are you trying to do?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 13, 2003, 12:48pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/12 "2003-04-13T12:48:45Z")

</div>

My mother is always saying i’m doing nothing all day (she right, but I don’t like to admit) So I decided to make something wich helps her administration. She should just enter the money she paid and the money she got, and then she would be able to see the balance. But it’s not working.

I’ll post a detailed fla right away…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 13, 2003, 12:54pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/13 "2003-04-13T12:54:45Z")

</div>

The second thing is not working.

If you enter a number, ex: 5. He will not show 27 (taxes inc) but he will paste it together; “521”; 5 and 21…

get it?:elderly:

(forgive my explanation, my english \*\*\*\*\*)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 13, 2003, 4:36pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/14 "2003-04-13T16:36:30Z")

</div>

Well it is a very simple solution, but the problem itself has me confused to no end. For some reason your script is parsing “e” as text so you are telling “f” to display the text inside “e” and 21 at the end of that.

Why it is only doing it for that textbox I have no clue since you have a whole bunch of other textboxes that work fine.

The solution is to use parseInt() which parses a string into an integer (given that string is an actual integer and not text)

[AS]a = 0;  
b = 0;  
e = 0;  
\_root.onEnterFrame = function() {  
c = a\*b;  
d = c+((c/100)\*21);  
f = parseInt(e)+21;  
};[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 13, 2003, 4:49pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/15 "2003-04-13T16:49:15Z")

</div>

What you could ALSO do here is give the textbox the INSTANCE name of the letter instead of the VAR name.

Why do this? Easy… because you can use “restrict” on the textbox that way 🙂

[AS]a.restrict = b.restrict=c.restrict=d.restrict=e.restrict=f.restrict=“0-9”;  
a.text = b.text=e.text=0;  
\_root.onEnterFrame = function() {  
c.text = a.text\*b.text;  
d.text = parseInt(c.text)+((c.text/100)\*21);  
f.text = parseInt(e.text)+21;  
};[/AS]

This restricts your input boxes to only be able to accept the characters 0-9 🙂

And oh yeah, while we are at it, you see how I chained my restricts and such. Why? Because ya can 😛

When the value of certain things are going to be the same you can string them a long like that.

For example… a.text, b.text, and e.text are all going to be equal to 0. Instead of writing down

a.text = 0  
b.text = 0  
e.text = 0

You can just write…

a.text = b.text = e.text = 0

🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 13, 2003, 7:25pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/16 "2003-04-13T19:25:25Z")

</div>

Cool, That really helped me out! Thanks a lot

Why didn’t flash wanted to accept mine?? I still don’t understand. Anyway, it’s working now.

Stil I do not get wat you do over here: can you explain that to me more detailed please?

> _Originally posted by lostinbeta \*  
> [AS]a.restrict = b.restrict=c.restrict=d.restrict=e.restrict=f.restrict=“0-9”;  
> a.text = b.text=e.text=0;  
> \_root.onEnterFrame = function() {  
> c.text = a.text_b.text;  
> d.text = parseInt(c.text)+((c.text/100)\*21);  
> f.text = parseInt(e.text)+21;  
> };[/AS]

BTW: Thanks for the last hint…  
:battery: 's up again

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 14, 2003, 3:09am UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/17 "2003-04-14T03:09:08Z")

</div>

[AS]a.restrict = b.restrict=c.restrict=d.restrict=e.restrict=f.restrict=“0-9”;  
a.text = b.text=e.text=0;  
\_root.onEnterFrame = function() {  
c.text = a.text\*b.text;  
d.text = parseInt(c.text)+((c.text/100)\*21);  
f.text = parseInt(e.text)+21;  
};[/AS]

This goes by if your textboxes have the INSTANCE names of a, b, c, d, e, and f. According to your file you have their VAR names as the letter (which is all well and good for the original way you had it, but for what I did here it needed to be the instance name).

[AS]a.restrict = b.restrict=c.restrict=d.restrict=e.restrict=f.restrict=“0-9”;[/AS]

The line above uses restrict feature in Flash to restrict the characters you can use in your input textbox. In this case, only the characters 0-9 can be used. Since there is no need for letters in this case… why allow the chance of accidently hitting one?

[AS]a.text = b.text=e.text=0;[/AS]

As for this line above, well you probably already know what it does… but you may not know why I use .text.

When going by the instance name of a textbox you MUST use .text to be able to add text into the textbox, or retrieve the value of the string in the textbox. You don’t need to add .text when you are using the VAR name (actually it won’t work if you do), but you have to use it when you are using an INSTANCE name for your textbox.

That help at all?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 15, 2003, 4:03pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/18 "2003-04-15T16:03:47Z")

</div>

That’s just perfect!

Thanks Lost…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 15, 2003, 4:23pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/19 "2003-04-15T16:23:14Z")

</div>

Glad I could help 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 15, 2003, 4:25pm UTC](https://forum.kirupa.com/t/this-is-not-working-why/17902/20 "2003-04-15T16:25:30Z")

</div>

lost to the rescue again…

i’m confused no end to what it all means but it looks great ha ha
