# Calling different methods in class instances

**URL:** <https://forum.kirupa.com/t/calling-different-methods-in-class-instances/241495>\
**Category:** Uncategorized\
**Created:** [October 15, 2007, 12:34am UTC](https://forum.kirupa.com/t/calling-different-methods-in-class-instances/241495 "2007-10-15T00:34:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sasxa](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sasxa](https://forum.kirupa.com/u/sasxa)\
**Post date:** [October 15, 2007, 12:34am UTC](https://forum.kirupa.com/t/calling-different-methods-in-class-instances/241495/1 "2007-10-15T00:34:01Z")

</div>

Is there a way to call different methods from different class instances in 3rd class? I know it sounds confusing, but I’ll try to explain what i want (:

I have 2 classes:

```php

package {
    public dynamic class Box {
        
        public function Box() {
                Content.update(this);
            }
        }
        public function changeBox(changeValue:Number):void {
        }
    }
}

```

…and:

```php

package {
    public dynamic class Cylinder {
        
        public function Cylinder() {
                Content.update(this);
            }
        }
        public function changeCylinder(changeValue:Number):void {
        }
    }
}

```

…also there is a 3rd class that’s updating/calculating some stuff…

```php

package {
    public class Content {
        public static function update(object:*):void {
            // calculate stuff...
            // 
            // when done, call method changeBox or changeCylinder  
            // and pass result of calculation
        }
    }
}

```

So i need a way to call \*changeBox _or_ changeCylinder \*methods, depending on ‘who’ asked for update…

I’ve tried several things: passing method name as argument, referencing method through _public static dict: Dictionary_ in Content class, but can’t find a way that works… Also setting return type of Content.update function to Number and passing result that way isn’t solution - real example is little more complicated (: I believe function call() & apply() methods are what i really need, but can’t figure out how to use them 😑

Any ideas?
