# Access class return value

**URL:** <https://forum.kirupa.com/t/access-class-return-value/245134>\
**Category:** flash\
**Created:** [November 26, 2007, 7:49pm UTC](https://forum.kirupa.com/t/access-class-return-value/245134 "2007-11-26T19:49:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpann](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tpann](https://forum.kirupa.com/u/tpann)\
**Post date:** [November 26, 2007, 7:49pm UTC](https://forum.kirupa.com/t/access-class-return-value/245134/1 "2007-11-26T19:49:09Z")

</div>

OK, this is a follow-up to a recent post (for those who might recognize it).

I’m very confused about what I THINK is probably a simple concept. I want to send a value to a class and use the class’s return value. Below is an example, and I want to make sure you understand, THIS IS NOT what I’m actually trying to do – it’s just a very simple example of what I’m not able to do, and if I can answer this question hopefully I can extend the solution to my “real” project.

Here’s my AddFour class, which simply adds four to the number I passed to it:

```php

package {
 public class AddFour { 
  private var _num:Number;
  public function AddFour(num:Number):void {
   _num = num;
   init(_num);
  }
  private function init(_num:Number):Number {
   return _num + 4;
  }
 }
}

```

My problem is, I don’t know how to get to the returned value. How do I do that?

To wit: In my .fla file, I have this:

```php
var foo:AddFour = new AddFour(7);

```

If I add a few traces, I see that AddFour successfully adds four to seven to get 11. So far so good.

**But what do I do in my .fla file to get a variable whose value is what AddFour returns?**

BTW, if I follow the above line in my .fla file with

```php
trace("foo = " + foo);

```

…my trace is…

```php
foo = [object AddFour]

```

This makes sense to me. Again, I assume the answer is pretty simple and I’m just missing something fundamental. What I’m looking for is a line of code that will let me define a variable whose value will be the return value of AddFour. (And PLEASE don’t advise me to just do the math in my head. =) )

Thanks!
