# Variables in a function

**URL:** <https://forum.kirupa.com/t/variables-in-a-function/260999>\
**Category:** Uncategorized\
**Created:** [May 21, 2008, 10:09pm UTC](https://forum.kirupa.com/t/variables-in-a-function/260999 "2008-05-21T22:09:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![8bit](https://avatars.discourse-cdn.com/v4/letter/8/90ced4/32.png) [@8bit](https://forum.kirupa.com/u/8bit)\
**Post date:** [May 21, 2008, 10:09pm UTC](https://forum.kirupa.com/t/variables-in-a-function/260999/1 "2008-05-21T22:09:59Z")

</div>

Hello, i think this might be a really dumb question , but anywausss. how do i get one function to recognize some of the variables that are created or modified inside another function

---

<div class="post-metadata">

**Author:** ![claudio](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@claudio](https://forum.kirupa.com/u/claudio)\
**Post date:** [May 25, 2008, 3:10pm UTC](https://forum.kirupa.com/t/variables-in-a-function/260999/2 "2008-05-25T15:10:08Z")

</div>

Just make sure that the variables that you need consistency in both functions are not local to any of them (you can easily point out a local variable by searching for the keyword \*\*\*var \*\*\*before its name, inside the body of the function; or if it’s a parameter of the function). I’m also assuming you have both function defined in the same scope.

```auto

function sum(a:Number,b:Number):Void{
	total = a + b;
}
function showResult():Void{
	trace(total);
}
//
sum(2,5);
showResult();

```
